Compare commits

..

173 Commits

Author SHA1 Message Date
John Crispin
4d0e34a194 patches: replace mediatek build tree hacks with fw3 variant (0061)
Remove obsolete mediatek-sdk build tree integration patches (0067, 0069)
and replace with a cleaner approach using a firewall3 default packages
variant. This simplifies the MediaTek SDK integration for OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5b9baf5119 patches: fix crypto module packaging for older kernels (0060)
The MediaTek SDK uses kernel 5.4.271 which requires adjustments to
the crypto module packaging:

1. The gf128mul module location changed between kernel versions:
   - Kernels < 6.2: crypto/gf128mul.ko
   - Kernels >= 6.2: lib/crypto/gf128mul.ko
   Add version-specific file paths to handle both locations.

2. The sha512-arm64 module doesn't exist in older ARM64 kernels like 5.4,
   causing package build failures. Exclude this module for the mt7981
   target which uses the older MediaTek SDK kernel.

These changes allow the kernel modules to build correctly whilst
maintaining compatibility with newer kernel versions.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
3b1ccdf4e9 patches: add kernel 5.4.271 hash for MediaTek SDK (0059)
Add kernel version and hash for MediaTek target using Linux 5.4.271
from the MediaTek SDK external feed.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a7313c707a patches: carry forward LED turnoff command (0058)
Adds a turnoff command to the LED script for disabling LEDs via the led command.

Renumbered from patches/0014.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5ee1804d86 patches: carry forward DHCP options 138 and 224 support (0057)
Adds support for DHCP option 138 (CAPWAP AC) and option 224 (private/site-specific) in netifd and busybox udhcpc.

Renumbered from patches/0101.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c4aeb0b3e1 patches: consolidate hostapd TIP patches (0056)
Consolidates all TIP-specific hostapd patches into a single patch including drop script, TIP extensions, shell scripts, global_ban support, builtin patches sync, and radar notification fixes.

Consolidated from patches 0020-0025.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
f753b0f226 patches: add ugps warning fixes (0055)
Silences compiler warnings in ugps build.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
7b7bddf633 patches: add ubox warning fixes (0054)
Silences compiler warnings in ubox build.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
b21b7c5bb9 patches: carry forward Morse Micro iwinfo support (0053)
Adds iwinfo support for Morse Micro wireless chipsets.

Renumbered from patches/0089.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
24eaf6da9e patches: carry forward uci-defaults sync (0052)
Adds sync after uci-defaults execution to ensure changes are written to disk.

Renumbered from patches/0096.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
715e50abdd patches: carry forward WWAN modemmanager support (0051)
Calls modemmanager script to set up Quectel LTE modems for WWAN connectivity.

Renumbered from patches/0093.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c0e7c5d0fd patches: carry forward IPQ807x UBI force detach (0050)
Adds UBI force detach patch for IPQ807x to handle problematic UBI volumes.

Renumbered from patches/0071.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
d573996d08 patches: carry forward Japan channel 14 fix (0049)
Fixes channel 14 configuration in wireless regulatory database for Japan.

Renumbered from patches/0099.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
6c9df1c826 patches: carry forward yuncore ax820 partition update (0048)
Adds insta1 and insta2 partitions to yuncore ax820 device tree.

Renumbered from patches/0097.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
81f569ba54 patches: add IPQ807x sysupgrade config behaviour (0047)
Prevents carrying configuration over during sysupgrade on IPQ807x targets.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
7b83658bc5 patches: carry forward Indio UM-305AX device support (0046)
Adds device support for Indio UM-305AX on MT7621 platform.

Renumbered from patches/0058.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2a9713fc14 patches: add description to 0045-ramips-add-certificates-partitions
Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
53bbf45c48 patches: carry forward ramips certificates partition (0045)
Adds certificates partition to ramips device tree for secure storage.

Renumbered from patches/0057.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2031d7d0e3 patches: add EdgeCore EAP111 device fixes (0044)
Device-specific fixes for EdgeCore EAP111 MediaTek platform.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5bcec18afb patches: carry forward ucode nl80211 QCA support (0043)
Adds lib/nl80211 support for QCA WiFi 6/7 nl80211 operations in ucode.

Renumbered and updated from patches/0081.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
f3cb3fe4d7 patches: carry forward RTL8367C/S switch support (0042)
Adds compile option for RTL8367C/S switch support.

Renumbered from patches/0054.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
ba1763b01b patches: carry forward busybox NTP priority fix (0041)
Prevents using pool NTP servers if DHCP-provided NTP servers are available.

Renumbered from patches/0079.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
4c71fe5aee patches: carry forward fwtool EST support check (0040)
Checks for EST (Enrollment over Secure Transport) support if the certificate was issued via EST.

Renumbered from patches/0091.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
18de3bf9f3 patches: add gpio-button-hotplug compatibility fix (0039)
Fixes gpio-button-hotplug compilation on older kernel versions.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
408a880b49 patches: carry forward WiFi interface renaming revert (0038)
Reverts upstream WiFi interface/device renaming changes from <phy>-<type><index> back to traditional wlan<N> naming to maintain compatibility with existing configurations.

Renumbered from patches/0026. In 24.10 the script moved from mac80211 package to wifi-scripts package.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
48d003b3c8 patches: carry forward rootfs size increase (0037)
Increases rootfs size to 500M for targets requiring larger firmware images.

Renumbered and generalised from patches/0085.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
18a711ba1e patches: carry forward netifd PSK2+RADIUS support (0036)
Adds support for WPA2-PSK with RADIUS accounting (PSK2+RADIUS mode).

Renumbered from patches/0034.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
49942e244d patches: carry forward netifd swconfig reload optimisation (0035)
Only reloads swconfig if configuration actually changed, avoiding unnecessary switch resets.

Renumbered from patches/0033.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
4ab04dd3ff patches: carry forward netifd GCMP-256 support (0034)
Adds GCMP-256 as a cipher suite when SAE is enabled, particularly for 6GHz operation.

Renumbered from patches/0090.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
15c117ddf3 patches: carry forward India DFS region fix (0033)
Adds DFS region configuration for India wireless regulatory compliance.

Renumbered from patches/0073.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c66595294a patches: carry forward ubox log priority filtering (0032)
Adds log priority filtering capability to ubox logread.

Renumbered from patches/0075.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
4fa4b7ffe6 patches: carry forward libubox CLOCK_BOOTTIME (0031)
Uses CLOCK_BOOTTIME instead of CLOCK_MONOTONIC for better suspend/resume handling.

Renumbered from patches/0042.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
1451c0aa13 patches: carry forward libubox runqueue fix (0030)
Prevents clearing the cancelled flag when a runqueue task is cancelled.

Renumbered from patches/0041.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
8f21896227 patches: carry forward dnsmasq EDNS options (0029)
Enables EDNS configuration options including CPE-ID and other extensions.

Renumbered from patches/0039.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
9860aeb3e1 patches: carry forward dnsmasq ifb-dhcp ignore (0028)
Configures dnsmasq to ignore DHCP on the ifb-dhcp interface.

Renumbered from patches/0038.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
64309085e8 patches: carry forward yuncore ax820 SPI fix (0027)
Reduces SPI clock speed to 20MHz for yuncore ax820 to fix stability issues.

Renumbered from patches/0050.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
1e0b4da8c1 patches: carry forward ugps AFC fields (0026)
Adds AFC (Automated Frequency Coordination) related fields to ubus GPS info command.

Renumbered from patches/0076.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2837f4406a patches: carry forward busybox DHCP supersede fix (0025)
Fixes issue where DHCP client would sometimes send supersede requests incorrectly.

Renumbered from patches/0087.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
6bf7c2306d patches: carry forward busybox watchdog enable (0024)
Enables the watchdog tool in busybox configuration for device monitoring.

Renumbered from patches/0008.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
64af62042f patches: carry forward nand.sh removal (0023)
Removes nand.sh from base-files as NAND handling is now done by the sysupgrade framework.

Renumbered and generalised from patches/0065.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
ccdda654c0 patches: carry forward ucidef_set_wireless_macaddr_base (0022)
Adds helper function to set wireless MAC address base in board configuration.

Renumbered from patches/0083.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
d0dba71673 patches: carry forward interface generation disable (0021)
Prevents automatic generation of default network interfaces on first boot, allowing full uCentral control.

Renumbered from patches/0082.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
b37b1e4c6e patches: carry forward ucentral-schema hash tracking (0020)
Adds wlan-ucentral-schema revision hash to /etc/openwrt_release for version tracking.

Renumbered from patches/0087.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
affead153e patches: carry forward CI_FWSETENV support (0019)
Adds support for CI_FWSETENV environment variable for firmware environment manipulation.

Renumbered from patches/0018.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
4c640fa16e patches: carry forward ucidef_set_wifi_country (0018)
Adds helper function to set WiFi country code in board configuration.

Renumbered from patches/0017.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
fbf236413b patches: carry forward sysupgrade safety flag (0017)
Makes sysupgrade default to not preserving configuration unless explicitly requested with -f flag.

Renumbered from patches/0013.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a84610bbf1 patches: carry forward wlan-ap repo hash (0016)
Adds the wlan-ap repository hash to /etc/openwrt_release for version tracking.

Renumbered from patches/0012.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
04a294afec patches: carry forward banner update (0015)
Updates the login banner with TIP/OpenWiFi branding.

Renumbered from patches/0011.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
1a3a475e1c patches: carry forward default password setting (0014)
Sets the default root password to 'openwifi' for initial device access.

Renumbered from patches/0010.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
808b47789e patches: add serial console login enforcement (0013)
Forces users to log in on the serial console for security, removing automatic root access.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
e7b6c64058 patches: fix DTC compatibility for older kernels (0012)
Removes --no-interrupt-parent flag when using older device tree compilers that don't support this option.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a4efe206a4 patches: add kernel 6.1 hash support (0011)
Adds kernel 6.1 hash to build system for QSDK-based targets using this kernel version.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
7c58bbf586 patches: add kernel 5.4 hash support (0010)
Adds kernel 5.4 hash to build system, enabling legacy kernel support for older targets.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
7c75bb604c patches: add kernel 6.6 headers support (0009)
Always builds kernel 6.6 headers even for older kernels, ensuring compatibility for packages requiring newer kernel APIs.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
dfb097da95 patches: fix GENERIC_PLATFORM_DIR handling (0008)
Fixes GENERIC_PLATFORM_DIR handling for external targets to prevent build system conflicts.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
09f4938435 patches: add external target directory support (0007)
Introduces default location for external target directories, allowing custom targets to be maintained outside the main tree.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
58bdced835 patches: add QSDK kernel support (0006)
Adds build system support for Qualcomm SDK kernels, enabling builds with vendor-specific kernel versions.

New patch for 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
67c7b88f00 patches: carry forward MMC/QSDK image build support (0005)
Adds build system support for creating MMC and QSDK-format images.

Renumbered from patches/0004.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
901b58c7ea patches: carry forward mbedtls to openssl replacement (0004)
Replaces libustream-mbedtls with libustream-openssl throughout the tree for consistency with TIP infrastructure.

Renumbered from patches/0007.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
0252d1affc patches: carry forward uCentral state integration (0003)
Integrates uCentral state management into OpenWrt's base system, allowing device configuration and monitoring through the uCentral framework.

Renumbered from patches/0019.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5cfe4fe1ae patches: carry forward feed script updates (0002)
Updates the feed management script with TIP-specific modifications.

Carried forward from patches/0002.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c22b6bb63d patches: carry forward gen_config.py script (0001)
This script sets up the OpenWrt build tree based on profile definitions in profiles/.

Carried forward from patches/0001.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
464bbdec31 patches: remove ubus uc_ubus_have_uloop fix
Remove ubus uc_ubus_have_uloop fix as this change is already upstreamed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
27c619d1f8 patches: remove ipq50xx scsi-core compile fix
Remove ipq50xx scsi-core compile error fix as this is no longer needed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
22a0ac8c0e patches: remove firewall SSH on WAN patch
Remove firewall SSH on WAN patch as this is now handled in /etc/ucentral/ucentral.cfg.0000000001.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a4ebab1211 patches: remove ath79 patches
Remove ath79 device support and bridge-vlan patches as the ath79 target is no longer supported.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
d688ca3349 patches: remove generic patch folders patch
Remove patch allowing generic patch folders in targets as this is now handled differently in 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
91ba691871 patches: remove busybox udhcpc endless loop fix
Remove busybox udhcpc endless loop fix as this issue no longer exists in the busybox version included in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
b9d15e05d0 patches: remove patches no longer needed in 24.10
Remove mac80211 hostapd dependency, iwinfo 6E support, wireguard-tools kernel module selection, generic pstore, feed.conf, and download.mk git patches as these are no longer needed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
6c32244621 patches: remove lldp TIP tweaks patch
Remove lldp TIP tweaks patch as we now carry the lldpd package with TIP modifications in our feed.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a7d9cd9c17 patches: remove ipq53xx KERNEL_IPQ_MEM_PROFILE patch
Remove ipq53xx KERNEL_IPQ_MEM_PROFILE patch as this functionality has been merged into the main patch.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
71f180f1a5 patches: remove kernel v4.4 support patches
Remove patches for kernel v4.4 support as old kernel versions are no longer supported in 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
32aa5a06df patches: remove uboot-envtools patches
Remove ipq807x, ipq50xx, and udaya-id5 uboot-envtools patches as this logic has been moved to the target feeds.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
db0e623fa7 patches: remove netifd various backports
Remove netifd various backports patch as these changes are already upstreamed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
ab961eab1b patches: remove netifd VLAN awareness fix
Remove netifd VLAN awareness fix as this change is already upstreamed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
0229a3e262 patches: remove netifd bridge_isolate backport
Remove netifd bridge_isolate patch as this change is already upstreamed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
8290428121 patches: remove rstrip.sh FW binary patch
Remove rstrip.sh patch as this change is already upstreamed in OpenWrt 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
bb59295dfa patches: remove package version bump patches
Remove version bump patches for netifd, libubox, umdns, ustream-ssl, uclient, ugps, dropbear, and ubus as package versions are already updated in 24.10.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
3652188b34 ucentral-ap: remove deprecated packages
Remove usteer, usteer2, ustp, and udevmand from the common package list as they are no longer used.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
e2ebf6cec7 config: update to OpenWrt 24.10
Update the base OpenWrt branch from 23.05 to 24.10.3 and adjust the patch folder accordingly.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c178fd60b5 edgecore_eap111: update profile for 24.10
Update subtarget from mt7981 to filogic and simplify profile by removing mediatek feed and redundant configuration options.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
743d4914d2 hostapd: fix package version format in EXTRA_DEPENDS
Fix EXTRA_DEPENDS to use correct version format with 'r' prefix
(e.g., 2023.09.08~e5ccbfc6-r4 instead of 2023.09.08~e5ccbfc6-4)
to match OpenWrt 24.10's package versioning scheme. This resolves
the dependency resolution failure where wpad-openssl couldn't find
the matching hostapd-common version.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
b7fbdf3acb mm61xx: fix enum type mismatch for GCC 13 compatibility
Fix enum type mismatch issues that cause compilation errors with GCC 13.
The patch corrects function signatures to use proper enum types instead
of generic integer types where appropriate.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c0829b40fc mediatek-sdk: mac80211: fix kconf host tool compilation
Fix kconf Makefile to explicitly use gcc for host tools instead of
allowing the cross compiler to leak in. This ensures the build tools
are compiled with the host toolchain rather than the target toolchain.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
a62213669f feeds: reorganise mediatek-sdk patch structure for OpenWrt 24.10
OpenWrt 24.10 changed the expected directory structure for kernel
patches in feeds. Patches that were previously in feeds/<feed>/mediatek/
now need to be in feeds/<feed>/linux/generic/ to align with the new
feed structure.

This commit moves all kernel backport and configuration files from
feeds/mediatek-sdk/mediatek/ to feeds/mediatek-sdk/linux/generic/
to comply with the new layout requirements.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
dd6901c6c4 ucentral-schema: update to latest HEAD
34379aa cleanup: remove unused MDNS service schema (no-op service)
26ae111 cleanup: remove unused HTTP service template and schema
f080ab3 cleanup: remove unused rtty service template and schema
c0c1d97 cleanup: remove unused files
e142706 fix: restore missing admin_ui variable assignment and validation
25582fa fix: restore correct file path in quality_of_service.uc
b3da9da base/interface-ssid: fix certificates variable scoping for validation
41ae448 base/interface: comprehensive refactoring to new templating pattern
3ec4415 base/switch: refactor to new templating pattern
a4a6f08 base/spotfilter: refactor to new templating pattern
5cd9b66 base/interface-firewall: comprehensive refactoring to new templating pattern
0910040 base/interface-ssid: comprehensive refactoring to new templating pattern
1f7a122 base/interface-mesh: update to new templating pattern
146068d base/interface-ieee8021x: update to new templating pattern
c272931 base/interface-bridge-vlan: update to new templating pattern
ffd4c2c base/interface-captive: update to new templating pattern
696648b base/interface-ipv6: update to new templating pattern
7034597 base/interface-ipv4: update to new templating pattern
3ca71c1 base/interface-dhcp: update to new templating pattern
5626faa base/interface-common: update to new templating pattern
4d030b5 tests: remove example files and fix wpa2-radius.json comment issue
728a10b renderer: add shell.system() method and update captive template
b5ff4fd tests: remove vxlan and gre tests and improve failure reporting
097351f tests: standardize unit test inputs with minimal valid schema pattern
c2bd383 renderer: add math import and remove local requires for deterministic testing
5cc3039 tests: add deterministic math mock and fix copy-to-expected functionality
a0c03a2 tests: add getopt-style CLI and rename to clean executable
a5f15cc tests: improve debug output structure for integration tests
51375e6 tests: add silent debug output for integration tests
ff81174 tests: simplify directory structure by renaming integration/full to full
1ac83ce tests: consolidate duplicate filesystem imports
a50e8d1 tests: remove unnecessary global mock variable assignments
ce32b74 tests: standardize context creation pattern to eliminate mutation anti-patterns
ffb830b tests: add generic single test runner and shared process execution utilities
a79f8a5 tests: create generic single test runner and remove redundant code
4c5bda4 tests: create generic single test runner for both unit and integration tests
404e9ae tests: move integration/base tests to unit/base for proper override support
1018c6f tests: update integration test expected outputs for eap101 board
0f1bd51 tests: fix error handling to preserve stacktrace display for exceptions
49d94f4 tests: consolidate test framework execution and eliminate remaining duplication
91e71b6 tests: consolidate context creation and eliminate duplication patterns
6df4283 tests: consolidate helper utilities and eliminate code duplication
038a514 renderer: extract captive object to shared library and fix integration test mocking
2ae2590 renderer: extract routing_table object to shared library and fix mock files state
2b1bcfb tests: implement process isolation for integration tests to prevent file descriptor leaks
47b67e4 tests: add comprehensive integration testing for all example configurations
cd19590 tests: implement dynamic service discovery and fix MPSK mock
e16284a tests: implement dynamic board-specific wiphy and wifi device loading
5317dd2 tests: integrate wiphy library with real board wiphy data
901f177 renderer: extract wiphy object to shared library
8187b56 tests: use real board configuration files in mock filesystem
39470a0 tests: consolidate code between real and mock renderer
17448da tests: improve error reporting in test framework
a0d463e tests: extract UCI helpers to shared library and update test outputs
3f2f3e3 renderer: minor fixes found while testing on real HW
383bf8e renderer: extract ethernet object to shared library
84cd3db schema: generate updated files
4b426c8 tests: fix integration test framework missing functions
5adba79 tests: implement full configuration integration test framework
dcf2ef8 tests: enhance board test context with dynamic wiphy mock
7a17791 tests: enhance test runner reporting for unit vs integration tests
21fb3c6 base/base: update to new templating pattern
b96def9 tests: implement board-specific integration test framework
4b78b03 renderer: move board.json loading to global scope
81041b3 renderer/templates: remove redundant fs require calls
3231152 renderer/templates/base: remove redundant fs import
bc961e0 base/ethernet: update to new templating pattern
8afa7ae renderer/templates: merge poe.uc into ethernet.uc
62eaa5e tests: add ethernet base template test cases (Step 1)
7e1d756 renderer/templates/ethernet: fix missing boolean wrappers
c82a7a9 schema: validate timeouts field descriptions
f5f6c43 base/timeout: update to new templating pattern
ae504fa tests: add timeout base template test cases (Step 1)
02f6fa9 renderer/templates/timeout: fix syntax error with extra closing tag
0748776 schema: validate unit field descriptions
355ad67 base/unit: update to new templating pattern
ec1b712 renderer/templates/unit: refactor to use helper functions (Step 2)
f3dcc79 tests: add unit base template test cases (Step 1)
12fc839 tests: add mock shell object for password management functions
2ae69f4 docs: update TESTING.md to reflect new test framework architecture
8e1eb31 tests: add support for base template testing infrastructure
0173636 schema: validate admin_ui field descriptions
49fb411 services/admin_ui: update to new templating pattern
b6b298a tests: add admin_ui test cases
b3bcd80 tests: refactor test runner to import-based architecture with individual test counts
0906e81 tests: consolidate test framework and eliminate code duplication
437df91 schema: validate wifi_scan metrics field descriptions
7f83f39 metrics/wifi_scan: update to new templating pattern
9cdc01c tests: add wifi_scan metrics test cases
b5964e5 schema: validate wifi_frames metrics field descriptions
dc96fdf metrics/wifi_frames: update to new templating pattern
8530e1e tests: add wifi_frames metrics test cases
a96f4d8 schema: validate telemetry metrics field descriptions
050ac26 metrics/telemetry: update to new templating pattern
ee43cdb tests: add telemetry metrics test cases
5a5721d schema: validate statistics metrics field descriptions
66ecd0d metrics/statistics: update to new templating pattern
eab7543 tests: add statistics metrics test cases
107a562 schema: enhance realtime metrics documentation
6fe7857 metric/realtime: refactor to new templating patterns
7c5775d tests: add realtime metrics template test cases
ee67163 schema: regenerate the files
3d4da1f schema: validate health metrics field descriptions
7c13c52 metrics/health: update to new templating pattern
d1f2169 tests: add health metric test cases
90f6e60 tests: fix mock renderer to extract metrics variables
4ea8eec schema: validate dhcp_snooping metrics field descriptions
1b3fb93 metrics/dhcp_snooping: update to new templating pattern
ce1582c tests: add dhcp_snooping metric test cases
5bbe42e docs: extend REFACTOR.md to cover metric templates
0994c85 schema: validate rrm field descriptions
00b0079 services/rrm: update to new templating pattern
0f7fa1c tests: add rrm test cases
c7b7130 services/radius_proxy: enhance schema documentation
237c0b3 services/radius_proxy: update to new templating pattern
6185a5a tests: add radius_proxy test cases
569d14a services/radius_gw_proxy: update to new templating pattern
2893469 schema: validate quality_of_service field descriptions
4535634 services/quality_of_service: update to new templating pattern
435744e tests: add quality_of_service test cases
c6c89b5 tests: enhance mock-renderer with QoS JSON support
bd054a5 schema: enhance online-check service documentation
b83b9ac services/online_check: refactor to new templating pattern
59c4a07 tests: add online_check test cases
8abc697 schema: validate gps field descriptions
ed33d61 services/gps: update to new templating pattern
59dca34 tests: add gps test cases
2c6b87f schema: validate fingerprint field descriptions
8d58237 services/fingerprint: update to new templating pattern
5f8be0c tests: add fingerprint test cases
5f1dcff services/dhcp_snooping: update to new templating pattern
e6cfd5f tests: add dhcp_snooping test cases
acf3763 tests: enhance mock-renderer with lookup_by_interface_vlan function
9313004 schema: validate airtime_fairness field descriptions
9a483c9 services/airtime_fairness: update to new templating pattern
bcd446f tests: add airtime_fairness test cases
157f7cf captive: enhance schema documentation and examples
d0388e7 services/captive: update to new templating pattern
1c8c736 tests: add captive test cases
db3d220 tests: enhance mock-renderer with SSID-based interface lookup
5799615 schema: validate dhcp_relay field descriptions
f58a2b3 services/dhcp_relay: update to new templating pattern
21f1d72 tests: add dhcp_relay test cases
0c96e96 schema: validate dhcp_inject field descriptions
670c57f services/dhcp_inject: update to new templating pattern
d7895a2 tests: add dhcp_inject test cases
9925450 tests: enhance mock-renderer with SSID and ethernet port lookups
4adc799 docs: update REFACTOR.md with NTP service example
79a9dcc services/ntp: update to new templating pattern
1f3c2ea tests: add ntp test cases
dc99ee6 schema: validate mdns field descriptions
56cede4 services/mdns: update to new templating pattern
3f86a6d tests: add mdns test cases
2aef7f6 docs: add refactoring guidelines
b42e3cd services/ssh: update to new templating pattern
37ca498 tests: add ssh test cases
c005ec3 tests: add proper mockup service for the files module
962a961 services/ieee8021x: update to new templating pattern
2a6a151 tests: add ieee8021x test cases
faaa0ba services/lldp: update to new templating pattern
b9fdbb0 services/log: update to new templating pattern
f9dbf48 tests: add unit test harness
8851342 add new template guidelines and helper functions
5e88dcb .gitignore: update docs/ filtering
3c822a5 ipcalc: split the implementation out into a library
f7f3937 ip-collide: start using the log module
54dd256 health.uc: refactor the code
3cd8d1f state: split code up into modules and add try/catch block around everything

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
8facd2d15f ucentral-client: update package hash
Update package mirror hash as 24.10 uses a new digest algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
7a55643fe5 profiles: remove qcom al02 eval kit profiles
Remove the qcom_al02-c15 and qcom_al02-c4 profiles as they are early evaluation kit builds no longer in use.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
da3bede2b7 modemmanager: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
db23ca0d87 wpa_supplicant_s1g: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
e18becdb64 morsecli: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
00ee71c0a2 hostapd_s1g: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2acc5c5063 mm61xx: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
bb18af7e5c mt76: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c012f83b4d hostapd: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
9cd7a0475e nat46-qca: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2e5afc692f hostapd: update PKG_MIRROR_HASH for 24.10
Update the package mirror hash as OpenWrt 24.10 uses a new digest
algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
948946bb51 feeds: update package hashes
Update package mirror hashes for ucrun and bridger as 24.10 uses a new digest algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
0850f215c5 ucentral-schema: fix ucentral-gps init script to prevent boot log spam
Add quiet flag to uci command to suppress error messages when GPS
configuration doesn't exist, preventing unnecessary log spam during
boot.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
aed20d2516 ucentral-schema: fix onlinecheck init script to prevent boot log spam
Add quiet flag to uci command and check for empty interval to suppress
error messages when onlinecheck configuration doesn't exist, preventing
unnecessary log spam during boot.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
3f57866846 ucentral-event: fix wifiscan init script to prevent boot log spam
Add quiet flag to uci command to suppress error messages when event
configuration doesn't exist, preventing unnecessary log spam during
boot.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
27e9f05908 ucentral-client: fix init script file handling
Add file existence checks before reading gateway.json and initialise
variables to prevent boot log spam when configuration file doesn't
exist.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
e5b3a6506b cloud_discovery: fix init script file handling
Add file existence check before reading gateway.json, fix variable
assignment typo, and improve error output redirection to prevent boot
log spam when configuration files don't exist.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
d7adb9ec5f rtty: fix init script error handling
Fix variable quoting in test conditions and remove explicit stderr
redirects to improve error message handling and prevent boot log spam.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
f3cfa2be93 udnssnoop: fix init script to prevent boot log spam
Add quiet flag to uci command to suppress error messages when qosify
configuration doesn't exist, preventing unnecessary log spam during
boot.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
01f809d5c4 ucentral-tools: add clang-format configuration
Add clang-format configuration file used for code formatting.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
1ac05ccc68 ucentral-tools: format radiusprobe.c with clang-format
Apply clang-format and fix code quality issues found by cppcheck:
- Consistent pointer style
- Standardise indentation and brace style
- Improve code readability

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
d701eeda6b ucentral-tools: format firstcontact.c with clang-format
Apply clang-format and fix code quality issues found by cppcheck:
- Consistent pointer style
- Standardise indentation and brace style
- Improve code readability

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
31a2888b77 ucentral-tools: format dnsprobe.c with clang-format
Apply clang-format and fix code quality issues found by cppcheck:
- Consistent pointer style
- Standardise indentation and brace style
- Improve code readability

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
190bccf588 ucentral-tools: format dhcpdiscover.c with clang-format
Apply clang-format and fix code quality issues found by cppcheck:
- Consistent pointer style (char* → char *)
- Fix variable shadowing issues
- Improve error message formatting
- Standardise indentation and brace style

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
afdfb5aa4a ucentral-tools: modernise build system and remove ip-collide
Update CMakeLists.txt to CMake 3.10 with comprehensive compiler
warnings and security hardening flags. Add strict warning flags
(-Wall, -Wextra, -Werror plus ~30 additional checks) and security
features (stack protector, RELRO). Separate Debug/Release
configurations with appropriate optimisation flags.

Remove ip-collide tool from build and installation as it's no longer
needed.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
1c4bcd823d ucentral: add custom lldpd package
Add custom lldpd package with older UCI and SYSV init scripts. The
upstream init scripts have changed significantly in 24.10, and we
want to keep the tested version that is known to work.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
8701fb97d6 spotfilter: fix compilation with gcc13
Add missing header includes (linux/if_vlan.h and net/ndisc.h) for
gcc13 compatibility.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2018b327d8 rtty: fix compilation with gcc13
Add missing libgen.h header and fix basename usage for gcc13
compatibility.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
28c1c38faf libwebsockets: fix lws_tls_server_abort_connection compilation
Fix return type declaration for lws_tls_server_abort_connection to
match the expected signature for gcc13 compatibility.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
abb36ee1e4 qca-ssdk: fix rtl826xb PHY driver compilation with gcc13
Fix return type mismatch in phy_common_general_reg_mmd_set function
for gcc13 compatibility.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
91f443582f mac80211: fix ath12k driver compilation with gcc13
Fix various compilation issues in the ath12k driver for gcc13:
- Remove invalid ATH12K_DBG_WMI parameter from ath12k_warn calls
- Fix return type mismatch in ath12k_mac_he_gi_to_nl80211_he_gi

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
c093c9425f mac80211: fix kconf compilation with gcc13
Fix kconf Makefile to explicitly use gcc instead of $(CC) variable
for compatibility with gcc13 build environment.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2492a29324 ipq53xx: fix bootconfig driver compilation with gcc13
Fix CONFIG_EMMC macro to CONFIG_MMC for compatibility with gcc13
and newer kernel configurations.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
8d8eee1e87 qca-wifi-7: add batctl and batman-adv packages
Copy batctl and batman-adv packages from 23.05 as the 24.10 versions
do not compile after the upgrade.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
11575ca7c6 qca-wifi-7: update iwinfo and add wifi-scripts dependency
Update iwinfo to latest version (2024-10-20) and add the wifi-scripts
package to work with the latest WiFi configuration changes in OpenWrt
24.10.

The mac80211 package now depends on wifi-scripts, and the mirror hash
has been updated for the new digest algorithm.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
aa36bd4ccd ipq53xx: rename sysupgrade images from .tar to .bin
Standardise the sysupgrade image format across all IPQ5332-based
devices by renaming the output from .tar to .bin format.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5651c0f386 qca-wifi-7: remove qca-nss-clients package
Remove the qca-nss-clients package as it is not actively used and
causes errors during feed setup.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
18de2196a7 profiles: update feed name and sysupgrade image extension
Update device profiles to reflect the feed rename from ipq807x_v5.4
to qca-wifi-6, and change sysupgrade image extension from .tar to
.bin to match the new image format.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
43cb94c8f5 feeds: rename ipq807x_v5.4 to qca-wifi-6
Rename the ipq807x_v5.4 feed to qca-wifi-6 to align with the naming
convention used for qca-wifi-7. This change improves consistency and
better reflects the content, which encompasses WiFi 6 (802.11ax)
packages across various Qualcomm IPQ platforms (IPQ5018, IPQ6018,
IPQ8074, etc.).

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
805d4b8d09 feeds: remove hfcl feed
Remove the hfcl feed which contained workarounds for old bugs that
are now resolved in the mainline code.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
14769925cf feeds: remove qosify package
Remove the custom qosify package as the new upstream version from
OpenWrt 24.10 is now being used.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
9e98527320 feeds: remove udevmand package
Remove the deprecated udevmand package. Its functionality is now
handled directly in ucentral-schema.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
5019c58fc8 feeds: remove ustp package
Remove the deprecated and unused ustp package.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
81e4f4036f feeds: remove usteer package
Remove the deprecated and unused usteer package.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
3a060fe41f feeds: remove mcu feed
Remove the old and unused mcu feed which provided MCU firmware
management and communication utilities for Bluetooth-related
hardware.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
2018539a0c feeds: remove edgecore feed
Remove the old and unused edgecore feed which provided the ELTT2
(Edgecore Link Layer Test Tool) utility.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
9c90c62e0b feeds: remove bluetooth feed
Remove the old and unused bluetooth feed which provided generic
Bluetooth support including 6LoWPAN, iBeacon, NRF52840, and LED
indicator utilities.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
ff704b282f feeds: remove bluetooth-csr feed
Remove the old and unused bluetooth-csr feed which provided BlueZ
and CSR8811 Bluetooth chip support.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
82cb988e56 feeds: remove bluetooth-cc2652 feed
Remove the old and unused bluetooth-cc2652 feed which provided BLE
scanning and firmware flashing support for TI CC2652 chips.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-19 00:00:00 +02:00
John Crispin
207a592896 ucentral-client: set version to v4.1.1
Signed-off-by: John Crispin <john@phrozen.org>
2025-10-07 11:31:11 +02:00
John Crispin
1bae90f681 ucentral-schema: set version to v4.1.1
Signed-off-by: John Crispin <john@phrozen.org>
2025-10-07 11:30:57 +02:00
John Crispin
f2afe49977 ipq53xx: enable LED heartbeat trigger in kernel config
Enable CONFIG_LEDS_TRIGGER_HEARTBEAT to allow LED heartbeat
functionality when device goes offline. Without this kernel option,
the LED trigger mechanism was unavailable, preventing the LED from
flashing to indicate offline status.

Fixes: WIFI-14646
Signed-off-by: John Crispin <john@phrozen.org>
2025-10-02 15:38:50 +02:00
Jimmy Cheng
04cc064026 ath12k-wifi: update NWA50BE BDF files
Adjust 2.4G CCA threshold from 32 to 38 to avoid false detection

Fixes: WIFI-15164
Signed-off-by: Jimmy Cheng <jimmy.cheng@zyxel.com.tw>
2025-10-02 07:43:18 +02:00
John Crispin
14778e1d2f ucentral-event: add VLAN reference counting to prevent race condition
When a station roams between bands on the same VLAN, the vlan_remove
event from the old band can arrive after the vlan_add event from the
new band, causing the VLAN to be incorrectly deleted whilst still in use.

Add reference counting that tracks how many interfaces are using each
VLAN ID. Only create VLAN devices on the first reference and only
remove them when the last reference is dropped.

On startup, initialise refcounts from current station state to handle
daemon restarts correctly.

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-01 16:19:01 +02:00
John Crispin
9712ce581f ucentral-schema: update to latest HEAD
676e155 dhcp_inject: fix a syntax issue in dhcp_inject
e594c44 captive.uam.mac-auth: the default was wrong

Signed-off-by: John Crispin <john@phrozen.org>
2025-10-01 16:19:01 +02:00
pratibha
a4dbeb376e ipq50xx: Add support for Indio-525AXM outdoor AP
Fixes: WIFI-14454
Signed-off-by: pratibha <pratibha.kuril@indionetworks.com>
2025-10-01 16:19:01 +02:00
jackcybertan
02b0457b28 ipq53xx: fix RAP750W-311A LAN ports
LAN switch exposes single eth1 instead of per-port interfaces for RAP750W-311A.
Using VLAN to separate LAN to each physical port for RAP750W-311A.

Fixes: WIFI-15163
Signed-off-by: jackcybertan <jack.tsai@cybertan.com.tw>
2025-10-01 16:19:01 +02:00
Shubham Vishwakarma
42007a147f update setup.py: make the profiles symlink relative instead of absolute
make openwrt/profiles relative so moving or renaming the repo directory won't break the symlink

Signed-off-by: Shubham Vishwakarma <shubhamvis98@fossfrog.in>
2025-10-01 07:44:35 +02:00
Shubham Vishwakarma
d1e18425b0 ramips: mt7621: update mt7621 indio um-305ax patch file
Changelog:
- Fix MAC address assignment for Ethernet ports
- Fix Ethernet port configuration (was not working in the current DTS
  because GPIOs 23 and 24, used for LEDs, are RGMII2 pins)
- Add package kmod-7915-firmware to enable Wi-Fi

Signed-off-by: Shubham Vishwakarma <shubhamvis98@fossfrog.in>
2025-10-01 07:44:35 +02:00
Arif Alam
d98e18a143 wifi_max_user: read data from correct phy index for EAP112
Set max_ap_assoc at wiphy init instead of vif init for mt7915.
Hard code max_ap_assoc to 128 for EAP112 in wifi_max_user.uc

Fixes WIFI-15027
Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2025-09-29 06:31:51 +02:00
Tanya Singh
fd170fabed hostapd: initialize ht/vht/he mode on channel switch by default while using hostapd_cli chan_switch command
Fixes: WIFI-14859
Signed-off-by: Tanya Singh <tanya_singh@accton.com>
2025-09-25 11:01:52 +02:00
John Crispin
9b2d80f2b4 ucentral-schema: update to latest HEAD
100c045 Fix cloud cannot show association list when WDS-AP in state.uc
168f6a4 dhcp_inject: Support multiple upstream

Signed-off-by: John Crispin <john@phrozen.org>
2025-09-24 13:10:36 +02:00
Sebastian Huang
5c892e7a0c mediatek-sdk: Support AN8801SB PHY for EAP112
Signed-off-by: Sebastian Huang <sebastian_huang@accton.com>
2025-09-24 12:51:49 +02:00
Shubham Vishwakarma
6ed93db422 ipq5018: add support for indio um-335ax
**Specifications:**
SOC: Qualcomm IPQ5018 (64-bit dual-core ARM Cortex-A53 @ 1.0Ghz)
Flash: SPI NOR 8MB (Winbond W25Q64DW) + NAND 128MB (Winbond W25N01GWZEIG)
Memory: 512MB DDR3L
Standard: 802.11ax/ac/b/g/n
2.4G Frequency: 2.4GHz - 2.484GHz
2.4G Wi-Fi standard: 802.11b/g/n/ax
5G Chipset: QCN9074
5G Frequency: 5.150GHz~5.850GHz
5G Wi-Fi Standard: 802.11 a/n/ac/ax
Buttons: 1 * Reset button, press 10 seconds to revert to default setting
2.4G Antenna: 2*2.4GHz/5.8GHz dual band antenna: 4dBi
5G Antenna: 2*5.8G antenna: 4dBi
Data Rate: 2.4GHz: 574Mbps, 5GHz:4800Mbps
Power: PoE 802.3at,DC2.0 12V/2A
Max Power Consumption: < 22W
LED Light: WAN, LAN, tricolor LED(sys-red, 2.4G-green, 5.8G-blue)

**BACKUP YOUR STOCK FIRMWARE:**
- Put openwrt-*-initramfs-kernel.bin to your TFTP server and rename it to initramfs.bin
- Enable serial console and enter to u-boot cli and exec these commands:
	```
	tftpboot <your_tftp_server_ip>:initramfs.bin
	bootm
	```
- Once boot completed and you get the openwrt shell execute below commands:
	```
	device=um335ax
	mkdir -p /tmp/fw_backup; cd /tmp/fw_backup
	rootfs=$(cat /proc/mtd | grep \"rootfs\" | cut -d: -f1)
	rootfs_1=$(cat /proc/mtd | grep \"rootfs_1\" | cut -d: -f1)
	dd if=/dev/${rootfs} of=rootfs_${rootfs} bs=1M
	dd if=/dev/${rootfs_1} of=rootfs_1_${rootfs_1} bs=1M
	cp /sys/firmware/fdt fdt.dtb
	md5sum * > md5sum
	tar -cvzf /tmp/${device}.tar.gz .
	sum=$(md5sum /tmp/${device}.tar.gz | cut -d' ' -f1)
	mv /tmp/${device}.tar.gz /tmp/${device}_${sum}.tar.gz
	echo "stock fw backup saved to: /tmp/${device}_${sum}.tar.gz"
	```
- Upload/save your backup to a safe place.

**STOCK FIRMWARE RECOVERY:**
- Boot initramfs image
- Upload your backed-up stock fw tarball to the device
	using scp or download it from the device using wget.
- Enter device ssh cli or tty and exec:
	```
	cd /tmp && wget <your_web_server_ip>/${stock_fw_backup}.tar.gz`
	tar -xpzf ${stock_fw_backup}.tar.gz
	rootfs=$(cat /proc/mtd | grep \"rootfs\" | cut -d: -f1)
	rootfs_1=$(cat /proc/mtd | grep \"rootfs_1\" | cut -d: -f1)
	ubiformat /dev/${rootfs} -y -f /tmp/rootfs_${rootfs}
	ubiformat /dev/${rootfs_1} -y -f /tmp/rootfs_1_${rootfs_1}
	reboot
	```

**INSTALLATION:**
1. initramfs method
- Put openwrt-*-initramfs-kernel.bin to your TFTP server and rename it to initramfs.bin
- Enable serial console and enter to u-boot cli and exec these commands:
	```
	tftpboot <your_tftp_server_ip>:initramfs.bin
	bootm
	```
- Once boot completed and you get the openwrt shell execute below commands:
	```
	cd /tmp && wget <your_web_server_ip>/factory.ubi`
	export rootfs=$(cat /proc/mtd | grep rootfs | cut -d: -f1)
	export rootfs_1=$(cat /proc/mtd | grep rootfs_1 | cut -d: -f1)
	ubiformat /dev/${rootfs} -y -f factory.ubi
	ubiformat /dev/${rootfs_1} -y -f factory.ubi
	reboot
	```

2. u-boot nand-factory.bin image method
- Put openwrt-*-squashfs-nand-factory.bin to your TFTP server and enter u-boot cli and exec these commands:
	```
	tftpboot <your_tftp_server_ip>:factory.bin
	#After downloading is finished:
	imxtract 0x44000000 ubi
	flash rootfs
	flash rootfs_1
	reset
	```

Signed-off-by: Shubham Vishwakarma <shubhamvis98@fossfrog.in>
2025-09-24 12:51:18 +02:00
Jimmy Cheng
92d67c15dd qca-ssdk: remove the unused patch of pinctrl
Signed-off-by: Jimmy Cheng <jimmy.cheng@zyxel.com.tw>
2025-09-24 12:50:29 +02:00
Marek Kwaczynski
460180f42e cloud_discovery: add blocklist for discovery methods
Introduce a blocklist mechanism to avoid retrying failed discovery
methods within the same discovery cycle. Each time a method fails
validation, it is added to the blacklist. The blacklist is cleared
once the device transitions to ONLINE or after all discovery methods
have been attempted.

This prevents repeated attempts of failing methods and ensures the
discovery process progresses more reliably.

Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2025-09-24 12:48:50 +02:00
Marek Kwaczynski
ed57759824 cloud_discovery: Skip rewriting discovery.state.json when no discovery metho d is set
In cases where gateway.json exists, the discovery method may be unset.
Writing an empty value to discovery.state.json is not useful, so
avoid updating the file in this case.

Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2025-09-24 12:48:50 +02:00
Marek Kwaczynski
957e3ca997 cloud_discovery: run est_client enroll before discovery process
Always obtain EST certificates before starting the discovery process.
This ensures certificates are already available from the EST server, since
the FQDN may be provided via DHCP discovery or another discovery method,
and requires valid certificates to proceed.

Fixes: WIFI-15123

Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2025-09-24 12:48:50 +02:00
John Crispin
7c2b8e8de0 ipq53xx: fix missing KERNEL_IPQ_MEM_PROFILE for multiple boards
Commit 2e4972e9ad ("ipq53xx: Add KERNEL_IPQ_MEM_PROFILE for IPQ53XX")
introduced KERNEL_IPQ_MEM_PROFILE but didn't set it for all IPQ53xx
boards, causing them to boot with incorrect RAM size settings.

This adds CONFIG_KERNEL_IPQ_MEM_PROFILE=0 to the affected board profiles:
- cig_wf189, cig_wf189h, cig_wf189w, cig_wf672
- edgecore_eap105
- sonicfi_rap7110c-341x

Signed-off-by: John Crispin <john@phrozen.org>
2025-09-24 11:57:42 +02:00
wingate5678
741007178f mount_certs: sonicfi squashfs certifiacte storage improve
Fixes: WIFI-15120
Signed-off-by: wingate5678 <wingate.chi@cybertan.com.tw>
2025-09-21 10:20:25 +02:00
Tanya Singh
e9d3e39d5e netifd: support DHCP options 138 and 224
Fixes: WIFI-14694
Signed-off-by: Tanya Singh <tanya_singh@accton.com>
2025-09-21 10:20:25 +02:00
wingate5678
b82a2c5da1 qca-wifi-7: sonicfi wifi7 thermal setting
Fixes: WIFI-15138
Signed-off-by: wingate5678 <wingate.chi@cybertan.com.tw>
2025-09-21 10:20:25 +02:00
Kumiko18
15429f39d8 udhcpinject: Support multiple upstream
Support multiple ssid <-> upstream bindings

Fixes: WIFI-15125
Signed-off-by: Kumiko18 <alex18_huang@accton.com>
2025-09-21 10:20:25 +02:00
Justin.Guo
5df274325b qca-wifi-7: Update WF672 FCC BDF
only support 2-band mode

Fixes: WIFI-15130
Signed-off-by: Justin.Guo <guoxijun@actiontec.com>
2025-09-21 10:20:25 +02:00
jackcybertan
2e4972e9ad ipq53xx: Add KERNEL_IPQ_MEM_PROFILE for IPQ53XX
Fixes: WIFI-15124
Signed-off-by: jackcybertan <jack.tsai@cybertan.com.tw>
2025-09-21 10:20:25 +02:00
John Crispin
a25480d479 hostapd: fix MAC overlap with MBSSID enabled
Reverse byte order in non-OUI part of MAC address to prevent overlap
when MBSSID is enabled. Swaps bytes 3 and 5 and masks lower nibble
of byte 5 before applying index XOR.

Signed-off-by: John Crispin <john@phrozen.org>
2025-09-21 10:20:25 +02:00
Jimmy Cheng
2f625c35f0 zyxel_nwa130be: use LED of DTS instead of ssdk cmd
Signed-off-by: Jimmy Cheng <jimmy.cheng@zyxel.com.tw>
2025-09-12 08:16:16 +02:00
Jimmy Cheng
b5422f80e4 qca-wifi-7: Zyxel NWA130BE save crash log into pstore
Signed-off-by: Jimmy Cheng <jimmy.cheng@zyxel.com.tw>
2025-09-12 08:16:16 +02:00
YenLin Pan
1ed503613d qca-wifi-7: Add Zyxel NWA50BE model
Signed-off-by: YenLin Pan <YenLin.Pan@zyxel.com.tw>
2025-09-12 08:16:16 +02:00
pratibha
f8954418f1 ipq50xx: Add support for Indio-525AXP wifi6 AP
Fixes: WIFI-14455
Signed-off-by: pratibha <pratibha.kuril@indionetworks.com>
2025-09-12 08:16:16 +02:00
John Crispin
3abc6a4463 ucentral-schema: update to latest HEAD
a1e7571 state: fix unassigned access

Signed-off-by: John Crispin <john@phrozen.org>
2025-09-12 08:16:16 +02:00
pratibha
811b63de93 ipq50xx: Support for Indio UM-325AX-V2 WiFi6 Indoor AP
Fixes: WIFI-14493
Signed-off-by: pratibha <pratibha.kuril@indionetworks.com>
2025-09-07 10:14:05 +02:00
Justin.Guo
c66020fbc6 qca-wifi-7: WF-672A, AFC pending, enable only 2-band mode
Fixes: WIFI-15000
Signed-off-by: Justin.Guo <guoxijun@actiontec.com>
2025-09-07 10:12:34 +02:00
jackcybertan
da7682166f ipq807x_v5.4/ipq50xx: enable pstore for rap630c-311g/rap630w-311g/rap630w-312g mt7621: enable pstore for rap63xc-211g
Signed-off-by: jackcybertan <jack.tsai@cybertan.com.tw>
2025-09-07 10:12:09 +02:00
John Crispin
bd50dfdf96 udhnssnoop: move the code directly into the repo
Signed-off-by: John Crispin <john@phrozen.org>
2025-09-07 10:05:15 +02:00
John Crispin
cbf0e536df udevmand: move the code directly into the repo
Signed-off-by: John Crispin <john@phrozen.org>
2025-09-07 10:04:06 +02:00
John Crispin
20a7a48c9f ucentral-tools: the git repo is gone, move the code into the package
Signed-off-by: John Crispin <john@phrozen.org>
2025-09-07 10:02:15 +02:00
2535 changed files with 37434 additions and 39933 deletions

View File

@@ -1,7 +1,7 @@
repo: https://github.com/openwrt/openwrt.git
branch: openwrt-23.05
revision: e92cf0c46ffe3ac7fca936c18577bfb19eb4ce9e
branch: openwrt-24.10
revision: v24.10.3
output_dir: ./output
patch_folders:
- patches
- patches-24.10

View File

@@ -1,29 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ble_scan
PKG_VERSION:=1.0
PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/ble_scan
SECTION:=base
CATEGORY:=Utilities
TITLE:=ble_scan
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/ble_scan/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ble_scan $(1)/bin/
endef
define Package/ble_scan/extra_provides
echo "libc.so.6";
endef
$(eval $(call BuildPackage,ble_scan))

View File

@@ -1,47 +0,0 @@
#all: ble_scan
#ble_scan: ble_scan.o
# $(CC) $(LDFLAGS) ble_scan.o -o ble_scan
#blescan.o: ble_scan.c
# $(CC) $(CFLAGS) -c ble_scan.c
#clean:
# rm *.o ble_scan
#
#
# Author: Teunis van Beelen
#
# email: teuniz@protonmail.com
#
#
#CROSS-COMPILE:=../../../../../qsdk/staging_dir/toolchain-arm/bin/arm-openwrt-linux-
#CC:=$(CROSS-COMPILE)gcc
CC = gcc
CFLAGS = -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -Wtype-limits -O2
objects = rs232.o
all: ble_scan
ble_scan : $(objects) ble_scan.o
$(CC) $(CFLAGS) $(objects) ble_scan.o -o ble_scan
ble_scan.o : ble_scan.c rs232.h
$(CC) $(CFLAGS) -c ble_scan.c -o ble_scan.o
rs232.o : rs232.h rs232.c
$(CC) $(CFLAGS) -c rs232.c -o rs232.o
clean :
$(RM) ble_scan $(objects) ble_scan.o
#
#
#
#

View File

@@ -1,387 +0,0 @@
/**************************************************
file: ble_scan.c
purpose: Send HCI command to do BLE scan
compile with the command: gcc ble_scan.c rs232.c -Wall -Wextra -o2 -o ble_scan
**************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include "rs232.h"
#define TX 0
#define RX 1
#define BUF_SIZE 4095
#define FULL_BUF_SIZE BUF_SIZE*4
//#define DEBUG
#ifdef DEBUG
#else
#endif
int print_hex(int mode, unsigned char *buf, int size);
int rx_pkt_parser(unsigned char *buf, int size);
struct rx_packet_h{
unsigned char rxType;
unsigned char rxEventCode;
unsigned char rxDataLen;
unsigned char Event[2];
unsigned char Status;
};
struct event_cmd_st_h{
unsigned char OpCode[2];
unsigned char DataLength;
};
struct event_scn_evnt_rep_h{
unsigned char EventId[4];
unsigned char AdvRptEventType;
unsigned char AddressType;
unsigned char Address[6];
unsigned char PrimaryPHY;
unsigned char SecondaryPHY;
unsigned char AdvSid;
unsigned char TxPower;
unsigned char RSSI;
unsigned char DirectAddrType;
unsigned char DirectAddr[6];
unsigned char PeriodicAdvInt[2];
unsigned char DataLength[2];
//unsigned char *DataPtr;
};
int main()
{
int cport_nr,bdrate,n;
//cport_nr=0, /* /dev/ttyS0 (COM1 on windows) */
//bdrate=9600; /* 9600 baud */
cport_nr=39, /* (ttyMSM1 : 39) */
bdrate=115200; /* 115200 baud */
#ifdef DEBUG
clock_t t;
#endif
char mode[]={'8','N','1',0};
unsigned char buf[BUF_SIZE];
unsigned char full_buf[FULL_BUF_SIZE];
int full_buf_ptr = 0;
unsigned char HCIExt_ResetSystemCmd[] = {0x01, 0x1D, 0xFC, 0x01, 0x00 };
int HCIExt_ResetSystemCmd_length = 5;
unsigned char GAP_DeviceInitCmd[] = {0x01, 0x00, 0xFE, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int GAP_DeviceInitCmd_length = 12;
unsigned char GapScan_enableCmd[] = {0x01, 0x51, 0xFE, 0x06, 0x00, 0x00, 0xF4, 0x01, 0x28, 0x00 };
int GapScan_enableCmd_length = 10;
if(RS232_OpenComport(cport_nr, bdrate, mode, 0))
{
printf("Can not open comport\n");
return(0);
}
RS232_flushRXTX(cport_nr);
// send reset command
#ifdef DEBUG
t=clock();
print_hex(TX, HCIExt_ResetSystemCmd, HCIExt_ResetSystemCmd_length);
t=clock()-t;
printf("t=%ld\n",t); //60
#else
/* sleep for 60ms */
usleep(60000);
#endif
RS232_SendBuf(cport_nr, HCIExt_ResetSystemCmd, HCIExt_ResetSystemCmd_length);
/* sleep for 1 Second */
#ifdef DEBUG
t=clock();
#endif
usleep(1000000);
#ifdef DEBUG
t=clock()-t;
printf("CLOCKS_PER_SEC=%ld\n",t);
#endif
n = RS232_PollComport(cport_nr, buf, BUF_SIZE);
#ifdef DEBUG
t=clock();
print_hex(RX, buf, n);
t=clock()-t;
printf("t=%ld\n",t);
#else
/* sleep for 300ms */
usleep(300000);
#endif
// send device initial command
#ifdef DEBUG
t=clock();
print_hex(TX, GAP_DeviceInitCmd, GAP_DeviceInitCmd_length);
t=clock()-t;
printf("t=%ld\n",t);
#else
/* sleep for 250 ms */
usleep(250000);
#endif
RS232_SendBuf(cport_nr, GAP_DeviceInitCmd, GAP_DeviceInitCmd_length);
/* sleep for 0.5 Second */
usleep(500000);
n = RS232_PollComport(cport_nr, buf, BUF_SIZE);
#ifdef DEBUG
t=clock();
print_hex(RX, buf, n);
t=clock()-t;
printf("t=%ld\n",t);
#else
/* sleep for 500 ms */
usleep(500000);
#endif
// send scan command
#ifdef DEBUG
t=clock();
print_hex(TX, GapScan_enableCmd, GapScan_enableCmd_length);
t=clock()-t;
printf("t=%ld\n",t);
#else
/* sleep for 30ms */
usleep(30000);
#endif
RS232_SendBuf(cport_nr, GapScan_enableCmd, GapScan_enableCmd_length);
//read scan respone
while (n > 0)
{
/* sleep for 400 mS */
usleep(400000);
n = RS232_PollComport(cport_nr, buf, BUF_SIZE);
#ifdef DEBUG
t=clock();
print_hex(RX, buf, n);
t=clock()-t;
printf("t=%ld\n",t);
#endif
if (full_buf_ptr+n>FULL_BUF_SIZE)
{
#ifdef DEBUG
printf("buffer full. break.\n");
#endif
break;
}
memcpy(full_buf+full_buf_ptr, buf, n);
full_buf_ptr+=n;
#ifdef DEBUG
printf("n:%d, full_buf_ptr:%d\n",n, full_buf_ptr);
#endif
}
#ifdef DEBUG
print_hex(RX, full_buf, full_buf_ptr);
#endif
rx_pkt_parser( full_buf, full_buf_ptr);
#ifdef DEBUG
printf("n:%d, full_buf_ptr:%d\n",n, full_buf_ptr);
#endif
RS232_flushRXTX(cport_nr);
RS232_CloseComport(cport_nr);
return(0);
}
/**************************************************
Print buffer in HEX
**************************************************/
int print_hex(int mode, unsigned char *buf, int size)
{
int ii,jj;
if (mode == TX)
printf("TX: ");
else
printf("RX: ");
for(ii=0,jj=0; ii < size; ii++,jj++)
{
printf("%02X ",buf[ii]);
if (jj==15)
{
printf("\n");
jj = 0;
}
}
printf("\n");
return(0);
}
int rx_pkt_parser(unsigned char *buf, int size)
{
int pkt_index=0;
int pkt_size=0;
int temp_event=0;
int temp_EventId=0;
int total_device_count=0;
char szAddress[18];
struct rx_packet_h *rx_packet;
struct event_scn_evnt_rep_h *event_scn_evnt_rep;
#ifdef DEBUG
int dump_i=0;
unsigned char *pkt_ptr;
#endif
if(size<=0){printf("size error\n");return -1;}
printf("BLE scan start:\n");
rx_packet = (struct rx_packet_h *)(buf);
while(pkt_index<size)
{
#ifdef DEBUG
printf("--------------------------------------------------------------------\n");
printf("-Type : 0x%02X (%s)\n",rx_packet->rxType,rx_packet->rxType==0x4?"Event":"Unknown");
if(rx_packet->rxType!=0x4)
{
printf(" Type unknown, rxType:0x%02X, pkt_index:%d\n",rx_packet->rxType,pkt_index);
}
printf("-EventCode : 0x%02X (%s)\n",rx_packet->rxEventCode,rx_packet->rxEventCode==0xff?"HCI_LE_ExtEvent":"Unknown");
if(rx_packet->rxEventCode!=0xff)
{
printf(" EventCode unknown, rxEventCode:0x%02X, pkt_index:%d\n",rx_packet->rxEventCode,pkt_index);
}
printf("-Data Length : 0x%02X (%d) bytes(s)\n",rx_packet->rxDataLen,rx_packet->rxDataLen);
#endif
temp_event = (rx_packet->Event[1]<<8)+rx_packet->Event[0] ;
#ifdef DEBUG
printf(" Event : 0x%02X%02X (%d) ",rx_packet->Event[1],rx_packet->Event[0],temp_event);
if(temp_event==0x067F)
{
printf("(GAP_HCI_ExtentionCommandStatus)\n");
}
else if(temp_event==0x0600)
{
printf("(GAP_DeviceInitDone)\n");
}
else if(temp_event==0x0613)
{
printf("(GAP_AdvertiserScannerEvent)\n");
}
else
{
printf(" Event unknown, Event:0x%04X, pkt_index:%d\n",temp_event,pkt_index);
}
printf(" Status : 0x%02X (%d) (%s)\n",rx_packet->Status,rx_packet->Status,rx_packet->Status==0?"SUCCESS":"FAIL");
#endif
if(temp_event==0x0613)
{
event_scn_evnt_rep = (struct event_scn_evnt_rep_h *)(&(rx_packet->Status) + 1);
temp_EventId = (event_scn_evnt_rep->EventId[3]<<24) + (event_scn_evnt_rep->EventId[2]<<16) +
(event_scn_evnt_rep->EventId[1]<<8) + (event_scn_evnt_rep->EventId[0]) ;
#ifdef DEBUG
printf(" EventId : 0x%02X%02X%02X%02X (%d) ", event_scn_evnt_rep->EventId[3],
event_scn_evnt_rep->EventId[2],
event_scn_evnt_rep->EventId[1],
event_scn_evnt_rep->EventId[0],temp_EventId);
if(temp_EventId==0x00010000)
{
printf("(GAP_EVT_SCAN_ENABLED)\n");
}
else if(temp_EventId==0x00020000)
{
printf("(GAP_EVT_SCAN_DISABLED)\n");
}
else if(temp_EventId==0x00400000)
{
printf("(GAP_EVT_ADV_REPORT)\n");
}
else
{
printf(" EventId unknown, EventId:0x%08X, pkt_index:%d\n",temp_EventId,pkt_index);
}
#endif
if(temp_EventId==0x00400000)
{
sprintf(szAddress,"%02X:%02X:%02X:%02X:%02X:%02X", event_scn_evnt_rep->Address[5],
event_scn_evnt_rep->Address[4],
event_scn_evnt_rep->Address[3],
event_scn_evnt_rep->Address[2],
event_scn_evnt_rep->Address[1],
event_scn_evnt_rep->Address[0]);
#ifdef DEBUG
printf("%04d", total_device_count);
printf(" Address : %s", szAddress);
printf(" RSSI : 0x%02X (%d)(%d)",event_scn_evnt_rep->RSSI,event_scn_evnt_rep->RSSI,event_scn_evnt_rep->RSSI-256);
#else
printf(" Address: %s RSSI: %d", szAddress, event_scn_evnt_rep->RSSI-256);
#endif
printf("\n");
total_device_count++;
}
}
pkt_size = 3+rx_packet->rxDataLen;
#ifdef DEBUG
pkt_ptr = (unsigned char *)rx_packet;
printf(" <Info > Dump(Rx):");
for(dump_i=0; dump_i < pkt_size; dump_i++)
{
if (dump_i%16==0)
{
printf("\n");
printf("%04x:",dump_i);
}
printf("%02X ",pkt_ptr[dump_i]);
}
printf("\n");
#endif
pkt_index+=pkt_size;
#ifdef DEBUG
printf(" pkt_size:%d, pkt_index:%d\n",pkt_size,pkt_index);
#endif
rx_packet = (struct rx_packet_h *)(&(rx_packet->rxDataLen) + rx_packet->rxDataLen + 1);
}
printf("Total: %d Device found.\n",total_device_count);
return 0;
}

View File

@@ -1,879 +0,0 @@
/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2005 - 2021 Teunis van Beelen
*
* Email: teuniz@protonmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************
*/
/* Last revision: February 9, 2021 */
/* For more info and how to use this library, visit: http://www.teuniz.net/RS-232/ */
#include "rs232.h"
#if defined(__linux__) || defined(__FreeBSD__) /* Linux & FreeBSD */
#define RS232_PORTNR 40
int Cport[RS232_PORTNR],
error;
struct termios new_port_settings,
old_port_settings[RS232_PORTNR];
const char *comports[RS232_PORTNR]={"/dev/ttyS0","/dev/ttyS1","/dev/ttyS2","/dev/ttyS3","/dev/ttyS4","/dev/ttyS5",
"/dev/ttyS6","/dev/ttyS7","/dev/ttyS8","/dev/ttyS9","/dev/ttyS10","/dev/ttyS11",
"/dev/ttyS12","/dev/ttyS13","/dev/ttyS14","/dev/ttyS15","/dev/ttyUSB0",
"/dev/ttyUSB1","/dev/ttyUSB2","/dev/ttyUSB3","/dev/ttyUSB4","/dev/ttyUSB5",
"/dev/ttyAMA0","/dev/ttyAMA1","/dev/ttyACM0","/dev/ttyACM1",
"/dev/rfcomm0","/dev/rfcomm1","/dev/ircomm0","/dev/ircomm1",
"/dev/cuau0","/dev/cuau1","/dev/cuau2","/dev/cuau3",
"/dev/cuaU0","/dev/cuaU1","/dev/cuaU2","/dev/cuaU3",
"/dev/ttyMSM0","/dev/ttyMSM1"};
int RS232_OpenComport(int comport_number, int baudrate, const char *mode, int flowctrl)
{
int baudr,
status;
if((comport_number>=RS232_PORTNR)||(comport_number<0))
{
printf("illegal comport number\n");
return(1);
}
switch(baudrate)
{
case 50 : baudr = B50;
break;
case 75 : baudr = B75;
break;
case 110 : baudr = B110;
break;
case 134 : baudr = B134;
break;
case 150 : baudr = B150;
break;
case 200 : baudr = B200;
break;
case 300 : baudr = B300;
break;
case 600 : baudr = B600;
break;
case 1200 : baudr = B1200;
break;
case 1800 : baudr = B1800;
break;
case 2400 : baudr = B2400;
break;
case 4800 : baudr = B4800;
break;
case 9600 : baudr = B9600;
break;
case 19200 : baudr = B19200;
break;
case 38400 : baudr = B38400;
break;
case 57600 : baudr = B57600;
break;
case 115200 : baudr = B115200;
break;
case 230400 : baudr = B230400;
break;
case 460800 : baudr = B460800;
break;
#if defined(__linux__)
case 500000 : baudr = B500000;
break;
case 576000 : baudr = B576000;
break;
case 921600 : baudr = B921600;
break;
case 1000000 : baudr = B1000000;
break;
case 1152000 : baudr = B1152000;
break;
case 1500000 : baudr = B1500000;
break;
case 2000000 : baudr = B2000000;
break;
case 2500000 : baudr = B2500000;
break;
case 3000000 : baudr = B3000000;
break;
case 3500000 : baudr = B3500000;
break;
case 4000000 : baudr = B4000000;
break;
#endif
default : printf("invalid baudrate\n");
return(1);
break;
}
int cbits=CS8,
cpar=0,
ipar=IGNPAR,
bstop=0;
if(strlen(mode) != 3)
{
printf("invalid mode \"%s\"\n", mode);
return(1);
}
switch(mode[0])
{
case '8': cbits = CS8;
break;
case '7': cbits = CS7;
break;
case '6': cbits = CS6;
break;
case '5': cbits = CS5;
break;
default : printf("invalid number of data-bits '%c'\n", mode[0]);
return(1);
break;
}
switch(mode[1])
{
case 'N':
case 'n': cpar = 0;
ipar = IGNPAR;
break;
case 'E':
case 'e': cpar = PARENB;
ipar = INPCK;
break;
case 'O':
case 'o': cpar = (PARENB | PARODD);
ipar = INPCK;
break;
default : printf("invalid parity '%c'\n", mode[1]);
return(1);
break;
}
switch(mode[2])
{
case '1': bstop = 0;
break;
case '2': bstop = CSTOPB;
break;
default : printf("invalid number of stop bits '%c'\n", mode[2]);
return(1);
break;
}
/*
http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html
http://man7.org/linux/man-pages/man3/termios.3.html
*/
Cport[comport_number] = open(comports[comport_number], O_RDWR | O_NOCTTY | O_NDELAY);
if(Cport[comport_number]==-1)
{
perror("unable to open comport ");
return(1);
}
/* lock access so that another process can't also use the port */
if(flock(Cport[comport_number], LOCK_EX | LOCK_NB) != 0)
{
close(Cport[comport_number]);
perror("Another process has locked the comport.");
return(1);
}
error = tcgetattr(Cport[comport_number], old_port_settings + comport_number);
if(error==-1)
{
close(Cport[comport_number]);
flock(Cport[comport_number], LOCK_UN); /* free the port so that others can use it. */
perror("unable to read portsettings ");
return(1);
}
memset(&new_port_settings, 0, sizeof(new_port_settings)); /* clear the new struct */
new_port_settings.c_cflag = cbits | cpar | bstop | CLOCAL | CREAD;
if(flowctrl)
{
new_port_settings.c_cflag |= CRTSCTS;
}
new_port_settings.c_iflag = ipar;
new_port_settings.c_oflag = 0;
new_port_settings.c_lflag = 0;
new_port_settings.c_cc[VMIN] = 0; /* block untill n bytes are received */
new_port_settings.c_cc[VTIME] = 0; /* block untill a timer expires (n * 100 mSec.) */
cfsetispeed(&new_port_settings, baudr);
cfsetospeed(&new_port_settings, baudr);
error = tcsetattr(Cport[comport_number], TCSANOW, &new_port_settings);
if(error==-1)
{
tcsetattr(Cport[comport_number], TCSANOW, old_port_settings + comport_number);
close(Cport[comport_number]);
flock(Cport[comport_number], LOCK_UN); /* free the port so that others can use it. */
perror("unable to adjust portsettings ");
return(1);
}
/* http://man7.org/linux/man-pages/man4/tty_ioctl.4.html */
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
tcsetattr(Cport[comport_number], TCSANOW, old_port_settings + comport_number);
flock(Cport[comport_number], LOCK_UN); /* free the port so that others can use it. */
perror("unable to get portstatus");
return(1);
}
status |= TIOCM_DTR; /* turn on DTR */
status |= TIOCM_RTS; /* turn on RTS */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
tcsetattr(Cport[comport_number], TCSANOW, old_port_settings + comport_number);
flock(Cport[comport_number], LOCK_UN); /* free the port so that others can use it. */
perror("unable to set portstatus");
return(1);
}
return(0);
}
int RS232_PollComport(int comport_number, unsigned char *buf, int size)
{
int n;
n = read(Cport[comport_number], buf, size);
if(n < 0)
{
if(errno == EAGAIN) return 0;
}
return(n);
}
int RS232_SendByte(int comport_number, unsigned char byte)
{
int n = write(Cport[comport_number], &byte, 1);
if(n < 0)
{
if(errno == EAGAIN)
{
return 0;
}
else
{
return 1;
}
}
return(0);
}
int RS232_SendBuf(int comport_number, unsigned char *buf, int size)
{
int n = write(Cport[comport_number], buf, size);
if(n < 0)
{
if(errno == EAGAIN)
{
return 0;
}
else
{
return -1;
}
}
return(n);
}
void RS232_CloseComport(int comport_number)
{
int status;
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
perror("unable to get portstatus");
}
status &= ~TIOCM_DTR; /* turn off DTR */
status &= ~TIOCM_RTS; /* turn off RTS */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
perror("unable to set portstatus");
}
tcsetattr(Cport[comport_number], TCSANOW, old_port_settings + comport_number);
close(Cport[comport_number]);
flock(Cport[comport_number], LOCK_UN); /* free the port so that others can use it. */
}
/*
Constant Description
TIOCM_LE DSR (data set ready/line enable)
TIOCM_DTR DTR (data terminal ready)
TIOCM_RTS RTS (request to send)
TIOCM_ST Secondary TXD (transmit)
TIOCM_SR Secondary RXD (receive)
TIOCM_CTS CTS (clear to send)
TIOCM_CAR DCD (data carrier detect)
TIOCM_CD see TIOCM_CAR
TIOCM_RNG RNG (ring)
TIOCM_RI see TIOCM_RNG
TIOCM_DSR DSR (data set ready)
http://man7.org/linux/man-pages/man4/tty_ioctl.4.html
*/
int RS232_IsDCDEnabled(int comport_number)
{
int status;
ioctl(Cport[comport_number], TIOCMGET, &status);
if(status&TIOCM_CAR) return(1);
else return(0);
}
int RS232_IsRINGEnabled(int comport_number)
{
int status;
ioctl(Cport[comport_number], TIOCMGET, &status);
if(status&TIOCM_RNG) return(1);
else return(0);
}
int RS232_IsCTSEnabled(int comport_number)
{
int status;
ioctl(Cport[comport_number], TIOCMGET, &status);
if(status&TIOCM_CTS) return(1);
else return(0);
}
int RS232_IsDSREnabled(int comport_number)
{
int status;
ioctl(Cport[comport_number], TIOCMGET, &status);
if(status&TIOCM_DSR) return(1);
else return(0);
}
void RS232_enableDTR(int comport_number)
{
int status;
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
perror("unable to get portstatus");
}
status |= TIOCM_DTR; /* turn on DTR */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
perror("unable to set portstatus");
}
}
void RS232_disableDTR(int comport_number)
{
int status;
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
perror("unable to get portstatus");
}
status &= ~TIOCM_DTR; /* turn off DTR */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
perror("unable to set portstatus");
}
}
void RS232_enableRTS(int comport_number)
{
int status;
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
perror("unable to get portstatus");
}
status |= TIOCM_RTS; /* turn on RTS */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
perror("unable to set portstatus");
}
}
void RS232_disableRTS(int comport_number)
{
int status;
if(ioctl(Cport[comport_number], TIOCMGET, &status) == -1)
{
perror("unable to get portstatus");
}
status &= ~TIOCM_RTS; /* turn off RTS */
if(ioctl(Cport[comport_number], TIOCMSET, &status) == -1)
{
perror("unable to set portstatus");
}
}
void RS232_flushRX(int comport_number)
{
tcflush(Cport[comport_number], TCIFLUSH);
}
void RS232_flushTX(int comport_number)
{
tcflush(Cport[comport_number], TCOFLUSH);
}
void RS232_flushRXTX(int comport_number)
{
tcflush(Cport[comport_number], TCIOFLUSH);
}
#else /* windows */
#define RS232_PORTNR 32
HANDLE Cport[RS232_PORTNR];
const char *comports[RS232_PORTNR]={"\\\\.\\COM1", "\\\\.\\COM2", "\\\\.\\COM3", "\\\\.\\COM4",
"\\\\.\\COM5", "\\\\.\\COM6", "\\\\.\\COM7", "\\\\.\\COM8",
"\\\\.\\COM9", "\\\\.\\COM10", "\\\\.\\COM11", "\\\\.\\COM12",
"\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16",
"\\\\.\\COM17", "\\\\.\\COM18", "\\\\.\\COM19", "\\\\.\\COM20",
"\\\\.\\COM21", "\\\\.\\COM22", "\\\\.\\COM23", "\\\\.\\COM24",
"\\\\.\\COM25", "\\\\.\\COM26", "\\\\.\\COM27", "\\\\.\\COM28",
"\\\\.\\COM29", "\\\\.\\COM30", "\\\\.\\COM31", "\\\\.\\COM32"};
char mode_str[128];
int RS232_OpenComport(int comport_number, int baudrate, const char *mode, int flowctrl)
{
if((comport_number>=RS232_PORTNR)||(comport_number<0))
{
printf("illegal comport number\n");
return(1);
}
switch(baudrate)
{
case 110 : strcpy(mode_str, "baud=110");
break;
case 300 : strcpy(mode_str, "baud=300");
break;
case 600 : strcpy(mode_str, "baud=600");
break;
case 1200 : strcpy(mode_str, "baud=1200");
break;
case 2400 : strcpy(mode_str, "baud=2400");
break;
case 4800 : strcpy(mode_str, "baud=4800");
break;
case 9600 : strcpy(mode_str, "baud=9600");
break;
case 19200 : strcpy(mode_str, "baud=19200");
break;
case 38400 : strcpy(mode_str, "baud=38400");
break;
case 57600 : strcpy(mode_str, "baud=57600");
break;
case 115200 : strcpy(mode_str, "baud=115200");
break;
case 128000 : strcpy(mode_str, "baud=128000");
break;
case 256000 : strcpy(mode_str, "baud=256000");
break;
case 500000 : strcpy(mode_str, "baud=500000");
break;
case 921600 : strcpy(mode_str, "baud=921600");
break;
case 1000000 : strcpy(mode_str, "baud=1000000");
break;
case 1500000 : strcpy(mode_str, "baud=1500000");
break;
case 2000000 : strcpy(mode_str, "baud=2000000");
break;
case 3000000 : strcpy(mode_str, "baud=3000000");
break;
default : printf("invalid baudrate\n");
return(1);
break;
}
if(strlen(mode) != 3)
{
printf("invalid mode \"%s\"\n", mode);
return(1);
}
switch(mode[0])
{
case '8': strcat(mode_str, " data=8");
break;
case '7': strcat(mode_str, " data=7");
break;
case '6': strcat(mode_str, " data=6");
break;
case '5': strcat(mode_str, " data=5");
break;
default : printf("invalid number of data-bits '%c'\n", mode[0]);
return(1);
break;
}
switch(mode[1])
{
case 'N':
case 'n': strcat(mode_str, " parity=n");
break;
case 'E':
case 'e': strcat(mode_str, " parity=e");
break;
case 'O':
case 'o': strcat(mode_str, " parity=o");
break;
default : printf("invalid parity '%c'\n", mode[1]);
return(1);
break;
}
switch(mode[2])
{
case '1': strcat(mode_str, " stop=1");
break;
case '2': strcat(mode_str, " stop=2");
break;
default : printf("invalid number of stop bits '%c'\n", mode[2]);
return(1);
break;
}
if(flowctrl)
{
strcat(mode_str, " xon=off to=off odsr=off dtr=on rts=off");
}
else
{
strcat(mode_str, " xon=off to=off odsr=off dtr=on rts=on");
}
/*
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363145%28v=vs.85%29.aspx
http://technet.microsoft.com/en-us/library/cc732236.aspx
https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_dcb
*/
Cport[comport_number] = CreateFileA(comports[comport_number],
GENERIC_READ|GENERIC_WRITE,
0, /* no share */
NULL, /* no security */
OPEN_EXISTING,
0, /* no threads */
NULL); /* no templates */
if(Cport[comport_number]==INVALID_HANDLE_VALUE)
{
printf("unable to open comport\n");
return(1);
}
DCB port_settings;
memset(&port_settings, 0, sizeof(port_settings)); /* clear the new struct */
port_settings.DCBlength = sizeof(port_settings);
if(!BuildCommDCBA(mode_str, &port_settings))
{
printf("unable to set comport dcb settings\n");
CloseHandle(Cport[comport_number]);
return(1);
}
if(flowctrl)
{
port_settings.fOutxCtsFlow = TRUE;
port_settings.fRtsControl = RTS_CONTROL_HANDSHAKE;
}
if(!SetCommState(Cport[comport_number], &port_settings))
{
printf("unable to set comport cfg settings\n");
CloseHandle(Cport[comport_number]);
return(1);
}
COMMTIMEOUTS Cptimeouts;
Cptimeouts.ReadIntervalTimeout = MAXDWORD;
Cptimeouts.ReadTotalTimeoutMultiplier = 0;
Cptimeouts.ReadTotalTimeoutConstant = 0;
Cptimeouts.WriteTotalTimeoutMultiplier = 0;
Cptimeouts.WriteTotalTimeoutConstant = 0;
if(!SetCommTimeouts(Cport[comport_number], &Cptimeouts))
{
printf("unable to set comport time-out settings\n");
CloseHandle(Cport[comport_number]);
return(1);
}
return(0);
}
int RS232_PollComport(int comport_number, unsigned char *buf, int size)
{
int n;
/* added the void pointer cast, otherwise gcc will complain about */
/* "warning: dereferencing type-punned pointer will break strict aliasing rules" */
if(!ReadFile(Cport[comport_number], buf, size, (LPDWORD)((void *)&n), NULL))
{
return -1;
}
return(n);
}
int RS232_SendByte(int comport_number, unsigned char byte)
{
int n;
if(!WriteFile(Cport[comport_number], &byte, 1, (LPDWORD)((void *)&n), NULL))
{
return(1);
}
if(n<0) return(1);
return(0);
}
int RS232_SendBuf(int comport_number, unsigned char *buf, int size)
{
int n;
if(WriteFile(Cport[comport_number], buf, size, (LPDWORD)((void *)&n), NULL))
{
return(n);
}
return(-1);
}
void RS232_CloseComport(int comport_number)
{
CloseHandle(Cport[comport_number]);
}
/*
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363258%28v=vs.85%29.aspx
*/
int RS232_IsDCDEnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_RLSD_ON) return(1);
else return(0);
}
int RS232_IsRINGEnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_RING_ON) return(1);
else return(0);
}
int RS232_IsCTSEnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_CTS_ON) return(1);
else return(0);
}
int RS232_IsDSREnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_DSR_ON) return(1);
else return(0);
}
void RS232_enableDTR(int comport_number)
{
EscapeCommFunction(Cport[comport_number], SETDTR);
}
void RS232_disableDTR(int comport_number)
{
EscapeCommFunction(Cport[comport_number], CLRDTR);
}
void RS232_enableRTS(int comport_number)
{
EscapeCommFunction(Cport[comport_number], SETRTS);
}
void RS232_disableRTS(int comport_number)
{
EscapeCommFunction(Cport[comport_number], CLRRTS);
}
/*
https://msdn.microsoft.com/en-us/library/windows/desktop/aa363428%28v=vs.85%29.aspx
*/
void RS232_flushRX(int comport_number)
{
PurgeComm(Cport[comport_number], PURGE_RXCLEAR | PURGE_RXABORT);
}
void RS232_flushTX(int comport_number)
{
PurgeComm(Cport[comport_number], PURGE_TXCLEAR | PURGE_TXABORT);
}
void RS232_flushRXTX(int comport_number)
{
PurgeComm(Cport[comport_number], PURGE_RXCLEAR | PURGE_RXABORT);
PurgeComm(Cport[comport_number], PURGE_TXCLEAR | PURGE_TXABORT);
}
#endif
void RS232_cputs(int comport_number, const char *text) /* sends a string to serial port */
{
while(*text != 0) RS232_SendByte(comport_number, *(text++));
}
/* return index in comports matching to device name or -1 if not found */
int RS232_GetPortnr(const char *devname)
{
int i;
char str[32];
#if defined(__linux__) || defined(__FreeBSD__) /* Linux & FreeBSD */
strcpy(str, "/dev/");
#else /* windows */
strcpy(str, "\\\\.\\");
#endif
strncat(str, devname, 16);
str[31] = 0;
for(i=0; i<RS232_PORTNR; i++)
{
if(!strcmp(comports[i], str))
{
return i;
}
}
return -1; /* device not found */
}

View File

@@ -1,85 +0,0 @@
/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2005 - 2021 Teunis van Beelen
*
* Email: teuniz@protonmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************
*/
/* For more info and how to use this library, visit: http://www.teuniz.net/RS-232/ */
#ifndef rs232_INCLUDED
#define rs232_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <string.h>
#if defined(__linux__) || defined(__FreeBSD__)
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <sys/file.h>
#include <errno.h>
#else
#include <windows.h>
#endif
int RS232_OpenComport(int, int, const char *, int);
int RS232_PollComport(int, unsigned char *, int);
int RS232_SendByte(int, unsigned char);
int RS232_SendBuf(int, unsigned char *, int);
void RS232_CloseComport(int);
void RS232_cputs(int, const char *);
int RS232_IsDCDEnabled(int);
int RS232_IsRINGEnabled(int);
int RS232_IsCTSEnabled(int);
int RS232_IsDSREnabled(int);
void RS232_enableDTR(int);
void RS232_disableDTR(int);
void RS232_enableRTS(int);
void RS232_disableRTS(int);
void RS232_flushRX(int);
void RS232_flushTX(int);
void RS232_flushRXTX(int);
int RS232_GetPortnr(const char *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@@ -1,37 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cc2652
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/cc2652
SECTION:=utils
CATEGORY:=Utilities
TITLE:=cc2652 -- TI CC26x2 firmware upgrade tool
DEPENDS:=+libstdcpp +zlib
endef
define Package/cc2652/description
TI CC26x2 firmware upgrade tool
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/cc2652/install
$(INSTALL_DIR) $(1)/lib/firmware/cc2562
$(INSTALL_BIN) ./files/firmware/* $(1)/lib/firmware/cc2562
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tisbl $(1)/usr/bin/
$(INSTALL_BIN) ./files/*.sh $(1)/usr/bin/
endef
$(eval $(call BuildPackage,cc2652))

View File

@@ -1,13 +0,0 @@
#!/bin/sh
if [ -f /sys/class/gpio/ble_enable/value ]; then
echo 1 > /sys/class/gpio/ble_enable/value
fi
echo 0 > /sys/class/gpio/ble_backdoor/value
echo 1 > /sys/class/gpio/ble_reset/value
echo 0 > /sys/class/gpio/ble_reset/value
sleep 1
echo 1 > /sys/class/gpio/ble_reset/value
sleep 1
echo 1 > /sys/class/gpio/ble_backdoor/value
tisbl /dev/ttyMSM1 115200 2652 /lib/firmware/cc2562/simple_broadcaster_bd9.bin

View File

@@ -1,13 +0,0 @@
#!/bin/sh
if [ -f /sys/class/gpio/ble_enable/value ]; then
echo 1 > /sys/class/gpio/ble_enable/value
fi
echo 0 > /sys/class/gpio/ble_backdoor/value
echo 1 > /sys/class/gpio/ble_reset/value
echo 0 > /sys/class/gpio/ble_reset/value
sleep 1
echo 1 > /sys/class/gpio/ble_reset/value
sleep 1
echo 1 > /sys/class/gpio/ble_backdoor/value
tisbl /dev/ttyMSM1 115200 2652 /lib/firmware/cc2562/ble5_host_test_bd9.bin

View File

@@ -1,10 +0,0 @@
#!/bin/sh
if [ -f /sys/class/gpio/ble_enable/value ]; then
echo 1 > /sys/class/gpio/ble_enable/value
fi
echo 1 > /sys/class/gpio/ble_backdoor/value
echo 1 > /sys/class/gpio/ble_reset/value
sleep 1
echo 1 > /sys/class/gpio/ble_reset/value
sleep 1

View File

@@ -1,13 +0,0 @@
#!/bin/sh
# com-wr.sh tty time command parser
# example com-wr.sh /dev/ttyMSM1 1 "\x01\x1D\xFC\x01\x00" | hexdump.sh --> send "\x01\x1D\xFC\x01\x00" to /dev/ttyMSM1 and then hexdump receive data until 100ms timeout
#command example "\x7E\x03\xD0\xAF und normaler Text"
tty=$1
time=$2
command=$3
parser=$4
stty -F $tty time $time
exec 99< $tty
echo -en $command > $tty
cat $tty
exec 99<&-

View File

@@ -1,28 +0,0 @@
#!/bin/sh
function iBeconScan() {
if [ "$#" -eq 4 ]; then
UUID=$1
MAJOR=$2
MINOR=$3
POWER=$4
else
UUID="\xE2\x0A\x39\xF4\x73\xF5\x4B\xC4\xA1\x2F\x17\xD1\xAD\x07\xA9\x61"
MAJOR="\x01\x23"
MINOR="\x45\x67"
POWER="\xC8"
fi
cc2562-wr.sh /dev/ttyMSM1 3 "\x01\x1D\xFC\x01\x00" > /dev/null # this command dealy time must >= 3, if small then 3, the following commands will be something wrong
cc2562-wr.sh /dev/ttyMSM1 1 "\x01\x00\xFE\x08\x01\x00\x00\x00\x00\x00\x00\x00" > /dev/null
cc2562-wr.sh /dev/ttyMSM1 1 "\x01\x3E\xFE\x15\x12\x00\xA0\x00\x00\xA0\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x7F\x01\x01\x00" > /dev/null
cc2562-wr.sh /dev/ttyMSM1 1 "\x09\x44\xFE\x23\x00\x00\x00\x1E\x00\x02\x01\x1A\x1A\xFF\x4C\x00\x02\x15${UUID}${MAJOR}${MINOR}${POWER}\x00" > /dev/null
cc2562-wr.sh /dev/ttyMSM1 1 "\x01\x3F\xFE\x04\x00\x00\x00\x00"
}
cc2562-reset.sh
while true
do
iBeconScan
sleep 1
done

View File

@@ -1,27 +0,0 @@
# Executable
EXE = tisbl
# Compiler, Linker Defines
#CC = g++
#CFLAGS = -w -O -Wno-deprecated -I. -fpermissive -std=gnu++0x
#CFLAGS = -I. -fpermissive -Wwrite-strings -lstdc++
CFLAGS = -I. -Wwrite-strings -std=gnu++0x -lstdc++ -fPIC
#CFLAGS = -I. -lstdc++ -Wwrite-strings -std=gnu++0x
#LIBS =
#LDFLAGS = $(LIBS)
# Compile and Assemble C++ Source Files into Object Files
%.o: %.cpp
$(CXX) $(CFLAGS) $(LDFLAGS) -c $< -o $@
# Source and Object files
SRC = $(wildcard *.cpp)
OBJ = $(patsubst %.cpp, %.o, $(SRC))
# Link all Object Files with external Libraries into Binaries
$(EXE): $(OBJ)
$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(EXE)
# $(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(EXE) -lz
.PHONY: clean
clean:
-rm -f $(EXE) *.o

View File

@@ -1,13 +0,0 @@
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <stdio.h>
#define DEBUG 0
#if defined(DEBUG) && DEBUG > 0
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, "$$%d:%s:%d:%s():" fmt, \
(int)time(NULL), __FILE__, __LINE__, __func__, ##args)
#else
#define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */
#endif
#endif // __DEBUG_H__

View File

@@ -1,257 +0,0 @@
/******************************************************************************
* Filename: sblAppEx.cpp
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader Library application example.
* This example enumerates all COM devices and lets you
* select which port to connect to. The example assumes the
* connected device is a CC2538, CC2650 or CC2652 and programs
* a blinky onto the device. After programming the blinky,
* bootloader mode may be forced by
* - holding SELECT button on 06EB (for CC2538 and CC26x0 EMKs), or
* - holding BTN-1 on the device LaunchPad (for CC26x2 LPs)
* when resetting the chip.
*
* Copyright (C) 2013 - 2019 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include "serialib.h"
#include "sbllib.h"
#include <vector>
#include <iostream>
#include <fstream>
//#include <time.h>
using namespace std;
// Calculate crc32 checksum the way CC2538 and CC2650 does it.
int calcCrcLikeChip(const unsigned char *pData, unsigned long ulByteCount)
{
unsigned long d, ind;
unsigned long acc = 0xFFFFFFFF;
const unsigned long ulCrcRand32Lut[] =
{
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC,
0x76DC4190, 0x6B6B51F4, 0x4DB26158, 0x5005713C,
0xEDB88320, 0xF00F9344, 0xD6D6A3E8, 0xCB61B38C,
0x9B64C2B0, 0x86D3D2D4, 0xA00AE278, 0xBDBDF21C
};
while ( ulByteCount-- )
{
d = *pData++;
ind = (acc & 0x0F) ^ (d & 0x0F);
acc = (acc >> 4) ^ ulCrcRand32Lut[ind];
ind = (acc & 0x0F) ^ (d >> 4);
acc = (acc >> 4) ^ ulCrcRand32Lut[ind];
}
return (acc ^ 0xFFFFFFFF);
}
/// Application status function (used as SBL status callback)
void appStatus(char *pcText, bool bError)
{
if(bError)
{
cerr << pcText;
}
else
{
cout << pcText;
}
}
/// Application progress function (used as SBL progress callback)
static void appProgress(uint32_t progress)
{
fprintf(stdout, "\r%d%% ", progress);
fflush(stdout);
}
// Defines
// Name Hex Dec
// ------------------------------- --------------- ---------------------------------
#define DEVICE_CC2538 0x2538 // 9528
#define DEVICE_CC26X0 0x2650 // 9808
#define DEVICE_CC2640R2 0x2640 // 9792
#define DEVICE_CC26X2 0x2652 // 9810
#define CC2538_FLASH_BASE 0x00200000
#define CC26XX_FLASH_BASE 0x00000000
// Application main function
// tisbl SerialDevNode baudRate deviceType firmware
int main(int argc, char *argv[])
{
// START: Program Configuration
/* UART baud rate. Default: 230400 */
uint32_t baudRate = 115200;
uint32_t deviceType = DEVICE_CC26X2;
SblDevice *pDevice = NULL; // Pointer to SblDevice object
char *SerialDevNode;
int32_t devStatus = -1; // Hold SBL status codes
std::string fileName; // File name to program
uint32_t byteCount = 0; // File size in bytes
uint32_t fileCrc, devCrc; // Variables to save CRC checksum
uint32_t devFlashBase; // Flash start address
static std::vector<char> pvWrite(1);// Vector to application firmware in.
static std::ifstream file; // File stream
// Set callback functions
SblDevice::setCallBackStatusFunction(&appStatus);
SblDevice::setCallBackProgressFunction(&appProgress);
// Select device
// deviceType FlashBase File
// DEVICE_CC2538 CC2538_FLASH_BASE blinky_backdoor_select_btn2538.bin
// DEVICE_CC26X0 CC26XX_FLASH_BASE blinky_backdoor_select_btn2650.bin
// DEVICE_CC2640R2 CC26XX_FLASH_BASE blinky_backdoor_select_btn2640r2.bin
// DEVICE_CC26X2 CC26XX_FLASH_BASE blinky_backdoor_select_btn26x2.bin
if(argc < 5) {
return -1;
}
SerialDevNode = argv[1];
baudRate = atoi(argv[2]);
deviceType = strtol(argv[3], NULL, 16);
fileName = argv[4];
switch(deviceType)
{
case DEVICE_CC2538:
devFlashBase = CC2538_FLASH_BASE;
break;
case DEVICE_CC26X0:
case DEVICE_CC2640R2:
case DEVICE_CC26X2:
devFlashBase = CC26XX_FLASH_BASE;
break;
}
printf("SerialDevNode=%s, baudRate=%d, deviceType=%04x, fileName=%s\n",SerialDevNode,baudRate,deviceType,fileName.c_str());
// Should SBL try to enable XOSC? (Not possible for CC26xx)
bool bEnableXosc = false;
if(deviceType == DEVICE_CC2538)
{
char answer[64];
cout << "Enable device CC2538 XOSC? (Y/N): ";
cin >> answer;
bEnableXosc = (answer[0] == 'Y' || answer[0] == 'y') ? true : false;
}
// Create SBL object
pDevice = SblDevice::Create(deviceType);
if(pDevice == NULL)
{
printf("No SBL device object.\n");
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Connect to device
printf("Connecting (%s @ %d baud) ...\n", SerialDevNode, baudRate);
if(pDevice->connect(SerialDevNode, baudRate, bEnableXosc) != SBL_SUCCESS)
{
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Read file
file.open(fileName.c_str(), std::ios::binary);
if(file.is_open())
{
// Get file size:
file.seekg(0, std::ios::end);
byteCount = (uint32_t)file.tellg();
file.seekg(0, std::ios::beg);
// Read data
pvWrite.resize(byteCount);
file.read((char*) &pvWrite[0], byteCount);
}
else
{
cout << "Unable to open file " << fileName.c_str();
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Calculate file CRC checksum
fileCrc = calcCrcLikeChip((unsigned char *)&pvWrite[0], byteCount);
if(pDevice->calculateCrc32(devFlashBase, byteCount, &devCrc) != SBL_SUCCESS)
{
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
printf ("pre-Comparing CRC: fileCrc=%x,devCrc=%x\n",fileCrc,devCrc);
if(fileCrc == devCrc) {
cout << "CRC is same, no need to upgrade\n";
pDevice->reset();
return 0;
}
// Erasing as much flash needed to program firmware.
cout << "Erasing flash ...\n";
if(pDevice->eraseFlashRange(devFlashBase, byteCount) != SBL_SUCCESS)
{
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Writing file to device flash memory.
cout << "Writing flash ...\n";
if(pDevice->writeFlashRange(devFlashBase, byteCount, &pvWrite[0]) != SBL_SUCCESS)
{
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Calculate CRC checksum of flashed content.
cout << "Calculating CRC on device ...\n";
if(pDevice->calculateCrc32(devFlashBase, byteCount, &devCrc) != SBL_SUCCESS)
{
cout << "\n\nAn error occurred: " << pDevice->getLastStatus();
return -1;
}
// Compare CRC checksums
printf ("Comparing CRC: fileCrc=%x,devCrc=%x\n",fileCrc,devCrc);
if(fileCrc == devCrc) printf("OK\n");
else printf("Mismatch!\n");
cout << "Resetting device ...\n";
pDevice->reset();
cout << "OK\n";
}

View File

@@ -1,673 +0,0 @@
/******************************************************************************
* Filename: sbl_device.cpp
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader device file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <sbllib.h>
#include "sbl_device.h"
#include "sbl_device_cc2538.h"
#include "sbl_device_cc2650.h"
#include "sbl_device_cc2652.h"
#if 0
#include <ComPort.h>
#include <ComPortElement.h>
#else
#include "serialib.h"
#endif
#include <stdarg.h>
// Static variables
//
std::string SblDevice::sm_csLastError;
uint32_t SblDevice::sm_progress = 0;
tProgressFPTR SblDevice::sm_pProgressFunction = NULL;
tStatusFPTR SblDevice::sm_pStatusFunction = NULL;
uint32_t SblDevice::sm_chipType = 0;
//-----------------------------------------------------------------------------
/** \brief Constructor
*/
//-----------------------------------------------------------------------------
SblDevice::SblDevice()
{
m_pCom = NULL;
m_lastDeviceStatus = -1;
m_lastSblStatus = SBL_SUCCESS;
m_bCommInitialized = false;
m_deviceId = 0;
m_ramSize = 0;
m_flashSize = 0;
m_pageEraseSize = 0;
}
//-----------------------------------------------------------------------------
/** \brief Destructor
*/
//-----------------------------------------------------------------------------
SblDevice::~SblDevice()
{
if (m_pCom != nullptr)
{
delete m_pCom;
m_pCom = nullptr;
}
m_lastDeviceStatus = -1;
m_bCommInitialized = false;
m_ramSize = -1;
m_flashSize = -1;
}
//-----------------------------------------------------------------------------
/** \brief Create Serial Bootloader Device
*
* \param[in] ui32ChipType
* Chip type the object should be created for, e.g. 0x2650 for CC2650.
*/
//-----------------------------------------------------------------------------
/*static*/SblDevice *
SblDevice::Create(uint32_t ui32ChipType)
{
if (ui32ChipType == 0)
{
return NULL;
}
sm_chipType = ui32ChipType;
switch (ui32ChipType)
{
case 0x2538:
return (SblDevice *)new SblDeviceCC2538();
case 0x1350:
case 0x1310:
case 0x2670:
case 0x2650:
case 0x2640:
case 0x2630:
case 0x2620:
return (SblDevice *)new SblDeviceCC2650();
case 0x1312:
case 0x1352:
case 0x2642:
case 0x2652:
return (SblDevice *)new SblDeviceCC2652();
default:
return NULL;
}
}
#if 0
//-----------------------------------------------------------------------------
/** \brief Enumerate COM port devices
*
* \param[in/out] pComPortElements
* Pointer to array where enumerated COM devices are stored
* \param[in/out] numElements
* Maximum number of elements to enumerate. Is populated with number
* of devices enumerated.
*
* \return
*
*/
//-----------------------------------------------------------------------------
/*static*/uint32_t
SblDevice::enumerate(ComPortElement *pComPortElements, int &numElements)
{
ComPort com;
if (com.enumerate(pComPortElements, numElements) != ComPort::COMPORT_SUCCESS)
{
printf("Failed to enumerate COM devices.\n");
return SBL_ENUM_ERROR;
}
return SBL_SUCCESS;
}
#endif
//-----------------------------------------------------------------------------
/** \brief Connect to given port number at specified baud rate.
*
* \param[in] csPortNum
* String containing the COM port to use
* \param[in] ui32BaudRate
* Baud rate to use for talking to the device.
* \param[in] bEnableXosc (optional)
* If true, try to enable device XOSC. Defaults to false. This option is
* not available for all device types.
*
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::connect(std::string csPortNum, uint32_t ui32BaudRate,
bool bEnableXosc/* = false*/)
{
DEBUG_PRINT("\n");
int retCode = SBL_SUCCESS;
//
// Check input arguments
//
if (csPortNum.empty() || ui32BaudRate == 0)
{
setState(SBL_ARGUMENT_ERROR, "Cannot connect. Port number '%s' or baud rate '%d' is invalid.\n",
csPortNum.c_str(), ui32BaudRate);
return SBL_ARGUMENT_ERROR;
}
// Try to connect to the specified port at the specified baud rate
if (m_pCom != NULL)
{
// Try to open port
#if 1
char result = m_pCom->openDevice(csPortNum.c_str(),ui32BaudRate);
if(result < 0)
{
setState(SBL_PORT_ERROR, "SBL: Unable to open %s. Error: %d.\n", csPortNum.c_str(), result);
return SBL_PORT_ERROR;
}
#else
if (int result = m_pCom->open(csPortNum,
ui32BaudRate,
SBL_DEFAULT_READ_TIMEOUT,
SBL_DEFAULT_WRITE_TIMEOUT) != ComPort::COMPORT_SUCCESS)
{
setState(SBL_PORT_ERROR, "SBL: Unable to open %s. Error: %d.\n", csPortNum.c_str(), result);
return SBL_PORT_ERROR;
}
#endif
m_csComPort = csPortNum;
m_baudRate = ui32BaudRate;
}
// Check if device is responding at the given baud rate
if ((retCode = initCommunication(bEnableXosc)) != SBL_SUCCESS)
{
return retCode;
}
//
// Read device ID
//
uint32_t tmp;
if ((retCode = readDeviceId(&tmp)) != SBL_SUCCESS)
{
setState(retCode, "Failed to read device ID during initial connect.\n");
return retCode;
}
//
// Read device flash size
//
if ((retCode = readFlashSize(&tmp)) != SBL_SUCCESS)
{
setState(retCode, "Failed to read flash size during initial connect.\n");
return retCode;
}
//
// Read device ram size
//
if ((retCode = readRamSize(&tmp)) != SBL_SUCCESS)
{
setState(retCode, "Failed to read RAM size during initial connect.\n");
return retCode;
}
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief Send auto baud.
*
* \param[out] bBaudSetOk
* True if response is ACK, false otherwise
*
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::sendAutoBaud(bool &bBaudSetOk)
{
DEBUG_PRINT("\n");
bBaudSetOk = false;
//
// Send 0x55 0x55 and expect ACK
//
char pData[2];
memset(pData, 0x55, 2);
if (m_pCom->writeBytes(pData, 2) != 2)
{
setState(SBL_PORT_ERROR, "Communication initialization failed. Failed to send data.\n");
return SBL_PORT_ERROR;
}
if (getCmdResponse(bBaudSetOk, 2, true) != SBL_SUCCESS)
{
// No response received. Invalid baud rate?
setState(SBL_PORT_ERROR, "No response from device. Device may not be in bootloader mode. Reset device and try again.\nIf problem persists, check connection and baud rate.\n");
return SBL_PORT_ERROR;
}
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief Get ACK/NAK from the boot loader.
*
* \param[out] bAck
* True if response is ACK, false if response is NAK.
* \param[in] ui32MaxRetries (optional)
* How many times ComPort::readBytes() can time out before fail is issued.
* \param[in] bQuietTimeout (optional)
* Do not set error if no command response is received.
*
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::getCmdResponse(bool &bAck,
uint32_t ui32MaxRetries/* = SBL_DEFAULT_RETRY_COUNT*/,
bool bQuietTimeout/* = false*/)
{
DEBUG_PRINT("\n");
unsigned char pIn[2];
memset(pIn, 0, 2);
uint32_t numBytes = 0;
uint32_t retry = 0;
bAck = false;
uint32_t bytesRecv = 0;
//
// Expect 2 bytes (ACK or NAK)
//
do
{
numBytes = m_pCom->readBytes(pIn, 2);
bytesRecv += numBytes;
retry++;
} while ((bytesRecv < 2) && (retry < ui32MaxRetries));
if (bytesRecv < 2)
{
if (!bQuietTimeout) setState(SBL_TIMEOUT_ERROR, "Timed out waiting for ACK/NAK. No response from device.\n");
return SBL_TIMEOUT_ERROR;
}
else
{
if (pIn[0] == 0x00 && pIn[1] == 0xCC)
{
bAck = true;
return setState(SBL_SUCCESS);
}
else if (pIn[0] == 0x00 && pIn[1] == 0x33)
{
return setState(SBL_SUCCESS);
}
else
{
setState(SBL_ERROR, "ACK/NAK not received. Expected 0x00 0xCC or 0x00 0x33, received 0x%02X 0x%02X. bytesRecv=%d\n", pIn[0], pIn[1], bytesRecv);
return SBL_ERROR;
}
}
return SBL_ERROR;
}
//-----------------------------------------------------------------------------
/** \brief Send command response (ACK/NAK).
*
* \param[in] bAck
* True if response is ACK, false if response is NAK.
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::sendCmdResponse(bool bAck)
{
DEBUG_PRINT("\n");
//
// Send response
//
char pData[2];
pData[0] = 0x00;
pData[1] = (bAck) ? 0xCC : 0x33;
if (m_pCom->writeBytes(pData, 2) != 2)
{
setState(SBL_PORT_ERROR, "Failed to send ACK/NAK response over %s\n",
m_csComPort.c_str());
return SBL_PORT_ERROR;
}
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief Get response data from device.
*
* \param[out] pcData
* Pointer to where received data will be stored.
* \param[in|out] ui32MaxLen
* Max number of bytes that can be received. Is populated with the actual
* number of bytes received.
* \param[in] ui32MaxRetries (optional)
* How many times ComPort::readBytes() can time out before fail is issued.
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::getResponseData(char *pcData, uint32_t &ui32MaxLen,
uint32_t ui32MaxRetries/* = SBL_DEFAULT_RETRY_COUNT*/)
{
DEBUG_PRINT("\n");
uint32_t numBytes = 0;
uint32_t retry = 0;
unsigned char pcHdr[2];
uint32_t numPayloadBytes;
uint8_t hdrChecksum, dataChecksum;
uint32_t bytesRecv = 0;
setState(SBL_SUCCESS);
//
// Read length and checksum
//
memset(pcHdr, 0, 2);
do
{
bytesRecv += m_pCom->readBytes(&pcHdr[bytesRecv], (2 - bytesRecv));
retry++;
} while ((bytesRecv < 2) && retry < ui32MaxRetries);
//
// Check that we've received 2 bytes
//
if (bytesRecv < 2)
{
setState(SBL_TIMEOUT_ERROR, "Timed out waiting for data header from device.\n");
return SBL_TIMEOUT_ERROR;
}
numPayloadBytes = pcHdr[0] - 2;
hdrChecksum = pcHdr[1];
//
// Check if length byte is too long.
//
if (numPayloadBytes > ui32MaxLen)
{
setState(SBL_ERROR, "Error: Device sending more data than expected. \nMax expected was %d, sent was %d.\n", (uint32_t)ui32MaxLen, (numPayloadBytes + 2));
#if 1
m_pCom->flushReceiver();
#endif
return SBL_ERROR;
}
//
// Read the payload data
//
bytesRecv = 0;
do
{
bytesRecv += m_pCom->readBytes(&pcData[bytesRecv], (numPayloadBytes - bytesRecv));
retry++;
} while (bytesRecv < numPayloadBytes && retry < ui32MaxRetries);
//
// Have we received what we expected?
//
if (bytesRecv < numPayloadBytes)
{
ui32MaxLen = bytesRecv;
setState(SBL_TIMEOUT_ERROR, "Timed out waiting for data from device.\n");
return SBL_TIMEOUT_ERROR;
}
//
// Verify data checksum
//
dataChecksum = generateCheckSum(0, pcData, numPayloadBytes);
if (dataChecksum != hdrChecksum)
{
setState(SBL_ERROR, "Checksum verification error. Expected 0x%02X, got 0x%02X.\n", hdrChecksum, dataChecksum);
return SBL_ERROR;
}
ui32MaxLen = bytesRecv;
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief Are we connected to the device?
*
* \return
* Returns true if connected to device.
* Returns false if not connected to device.
*/
//-----------------------------------------------------------------------------
bool
SblDevice::isConnected()
{
DEBUG_PRINT("\n");
if (!m_pCom)
{
return false;
}
return true;
}
//-----------------------------------------------------------------------------
/** \brief This function generates the bootloader protocol checksum.
*
* \param[in] ui32Cmd
* The bootloader command
* \param[in] pcData
* Pointer to the command data.
* \param[in] ui32DataLen
* Data length in bytes.
*
* \return
* Returns the generated checksum.
*/
//-----------------------------------------------------------------------------
uint8_t
SblDevice::generateCheckSum(uint32_t ui32Cmd, const char *pcData,
uint32_t ui32DataLen)
{
DEBUG_PRINT("\n");
uint8_t ui8CheckSum = (uint8_t)ui32Cmd;
for (uint32_t i = 0; i < ui32DataLen; i++)
{
ui8CheckSum += pcData[i];
}
return ui8CheckSum;
}
//-----------------------------------------------------------------------------
/** \brief This function sets the SBL status and the SBL error string.
*
* \param[in] ui32Status
* The new SBL status. SBL_SUCCESS, SBL_ERROR, ...
* \param[in] pcFormat
* 'printf' like format string.
* \param[in] ...
* Input variables to the \e pcFormat string.
*
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDevice::setState(const uint32_t &ui32Status, char *pcFormat, ...)
{
DEBUG_PRINT("\n");
va_list args;
char text[2048];
m_lastSblStatus = ui32Status;
// Attempt to do a sanity check. Not possible to say how long
// the formatted text will be, but if we reserve half the space for
// formatted arguments it should be sufficient.
if (strlen(pcFormat) > 2048 / 2) {
return SBL_ERROR;
}
va_start(args, pcFormat);
#if 0
vsprintf_s(text, pcFormat, args);
#else
vsprintf(text, pcFormat, args);
#endif
sm_csLastError = text;
va_end(args);
if (SblDevice::sm_pStatusFunction != NULL)
{
bool error = (m_lastSblStatus == SBL_SUCCESS) ? false : true;
sm_pStatusFunction((char *)sm_csLastError.c_str(), error);
}
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief Utility function for converting 4 elements in char array into
* 32 bit variable. Data are converted MSB, that is. \e pcSrc[0] is the
* most significant byte.
*
* \param pcSrc[in]
* A pointer to the source array.
*
* \return
* Returns the 32 bit variable.
*/
//-----------------------------------------------------------------------------
/*static */uint32_t
SblDevice::charArrayToUL(const char *pcSrc)
{
DEBUG_PRINT("\n");
uint32_t ui32Val = (unsigned char)pcSrc[3];
ui32Val += (((unsigned long)pcSrc[2]) & 0xFF) << 8;
ui32Val += (((unsigned long)pcSrc[1]) & 0xFF) << 16;
ui32Val += (((unsigned long)pcSrc[0]) & 0xFF) << 24;
return (ui32Val);
}
//-----------------------------------------------------------------------------
/** \brief Utility function for splitting 32 bit variable into char array
* (4 elements). Data are converted MSB, that is, \e pcDst[0] is the
* most significant byte.
*
* \param[in] ui32Src
* The 32 bit variable to convert.
*
* \param[out] pcDst
* Pointer to the char array where the data will be stored.
*
* \return
* void
*/
//-----------------------------------------------------------------------------
/*static */void
SblDevice::ulToCharArray(const uint32_t ui32Src, char *pcDst)
{
DEBUG_PRINT("\n");
// MSB first
pcDst[0] = (uint8_t)(ui32Src >> 24);
pcDst[1] = (uint8_t)(ui32Src >> 16);
pcDst[2] = (uint8_t)(ui32Src >> 8);
pcDst[3] = (uint8_t)(ui32Src >> 0);
}
//-----------------------------------------------------------------------------
/** \brief Utility function for swapping the byte order of a 4B char array.
*
* \param[in|out] pcArray
* The char array to byte swap.
*
* \return
* void
*/
//-----------------------------------------------------------------------------
/*static */void
SblDevice::byteSwap(char *pcArray)
{
DEBUG_PRINT("\n");
uint8_t tmp[2] = { (uint8_t)pcArray[0], (uint8_t)pcArray[1] };
pcArray[0] = pcArray[3];
pcArray[1] = pcArray[2];
pcArray[2] = tmp[1];
pcArray[3] = tmp[0];
}
//-----------------------------------------------------------------------------
/** \brief This functions sets the SBL progress.
*
* \param[in] ui32Progress
* The current progress, typically in percent [0-100].
*
* \return
* void
*/
//-----------------------------------------------------------------------------
/*static*/uint32_t
SblDevice::setProgress(uint32_t ui32Progress)
{
DEBUG_PRINT("\n");
if (sm_pProgressFunction)
{
sm_pProgressFunction(ui32Progress);
}
sm_progress = ui32Progress;
return SBL_SUCCESS;
}

View File

@@ -1,143 +0,0 @@
#ifndef __SBL_DEVICE_H__
#define __SBL_DEVICE_H__
/******************************************************************************
* Filename: sbl_device.h
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader device header file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include "serialib.h"
//
// Typedefs for callback functions to report status and progress to application
//
typedef void (*tStatusFPTR)(char *pcText, bool bError);
typedef void (*tProgressFPTR)(uint32_t ui32Value);
class SblDevice
{
public:
// Constructor
~SblDevice();
// Static functions
static SblDevice *Create(uint32_t ui32ChipType);
virtual uint32_t connect(std::string csPortNum, uint32_t ui32BaudRate, bool bEnableXosc = false);
virtual uint32_t ping() = 0;
virtual uint32_t readStatus(uint32_t *pui32Status) = 0;
virtual uint32_t readDeviceId(uint32_t *pui32DeviceId) = 0;
virtual uint32_t readFlashSize(uint32_t *pui32FlashSize) = 0;
virtual uint32_t readRamSize(uint32_t *pui32RamSize) = 0;
virtual uint32_t run(uint32_t ui32Address) { (void)ui32Address; return SBL_UNSUPPORTED_FUNCTION; };
virtual uint32_t reset() = 0;
virtual uint32_t eraseFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount) { (void)ui32StartAddress; (void)ui32ByteCount; return 0; };
virtual uint32_t writeFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount, const char *pcData) { (void)ui32StartAddress; (void)ui32ByteCount; (void)pcData; return 0; };
virtual uint32_t readMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, uint32_t *pui32Data) = 0;
virtual uint32_t readMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, char *pcData) = 0;
virtual uint32_t writeMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const uint32_t *pui32Data) = 0;
virtual uint32_t writeMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const char *pcData) = 0;
virtual uint32_t calculateCrc32(uint32_t ui32StartAddress, uint32_t ui32ByteCount, uint32_t *pui32Crc) = 0;
// CC2650 specific
virtual uint32_t eraseFlashBank(){ return SBL_UNSUPPORTED_FUNCTION; };
virtual uint32_t setCCFG(uint32_t ui32Field, uint32_t ui32FieldValue) { (void)ui32Field; (void)ui32FieldValue; return SBL_UNSUPPORTED_FUNCTION; };
// CC2538 specific
virtual uint32_t setXosc() { return SBL_UNSUPPORTED_FUNCTION; };
// Utility functions
bool isConnected();
uint32_t getDeviceId() { return m_deviceId; }
uint32_t getFlashSize() { return m_flashSize; }
uint32_t getRamSize() { return m_ramSize; }
uint32_t getBaudRate() { return m_baudRate; }
uint32_t getLastStatus() {return m_lastSblStatus; }
uint32_t getLastDeviceStatus() { return m_lastDeviceStatus; }
uint32_t getPageEraseSize() { return m_pageEraseSize; }
static std::string &getLastError(void) { return sm_csLastError;}
static uint32_t getProgress() { return sm_progress; }
static uint32_t setProgress(uint32_t ui32Progress);
static void setCallBackStatusFunction(tStatusFPTR pSf) {sm_pStatusFunction = pSf; }
static void setCallBackProgressFunction(tProgressFPTR pPf) {sm_pProgressFunction = pPf; }
protected:
// Constructor
SblDevice();
virtual uint32_t initCommunication(bool bSetXosc) = 0;
virtual uint32_t sendCmd(uint32_t ui32Cmd, const char *pcSendData = NULL, uint32_t ui32SendLen = 0) = 0;
virtual uint32_t sendAutoBaud(bool &bBaudSetOk);
virtual uint32_t getCmdResponse(bool &bAck, uint32_t ui32MaxRetries = SBL_DEFAULT_RETRY_COUNT, bool bQuiet = false);
virtual uint32_t sendCmdResponse(bool bAck);
virtual uint32_t getResponseData(char *pcData, uint32_t &ui32MaxLen, uint32_t ui32MaxRetries = SBL_DEFAULT_RETRY_COUNT);
virtual uint8_t generateCheckSum(uint32_t ui32Cmd, const char *pcData, uint32_t ui32DataLen);
virtual uint32_t addressToPage(uint32_t ui32Address) = 0;
virtual bool addressInRam(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1) = 0;
virtual bool addressInFlash(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1) = 0;
virtual uint32_t getBootloaderEnableAddress() = 0;
uint32_t setState(const uint32_t &ui32Status) { m_lastSblStatus = ui32Status; return m_lastSblStatus;}
uint32_t setState(const uint32_t &ui32Status, char *pcFormat, ...);
// Utility
static uint32_t charArrayToUL(const char *pcSrc);
static void ulToCharArray(const uint32_t ui32Src, char *pcDst);
static void byteSwap(char *pcArray);
serialib *m_pCom;
std::string m_csComPort;
bool m_bCommInitialized;
uint32_t m_baudRate;
static uint32_t sm_chipType;
uint32_t m_deviceId;
uint32_t m_flashSize;
uint32_t m_ramSize;
uint32_t m_pageEraseSize;
// Status and progress variables
int32_t m_lastDeviceStatus;
int32_t m_lastSblStatus;
static uint32_t sm_progress;
static std::string sm_csLastError;
static tProgressFPTR sm_pProgressFunction;
static tStatusFPTR sm_pStatusFunction;
private:
};
#endif // __SBL_DEVICE_H__

File diff suppressed because it is too large Load Diff

View File

@@ -1,126 +0,0 @@
#ifndef __SBL_DEVICE_CC2538_H__
#define __SBL_DEVICE_CC2538_H__
/******************************************************************************
* Filename: sbl_device_cc2538.h
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader for CC2538 header file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <sbl_device.h>
//
// For more information about the CC2538 serial bootloader interface,
// please refer to the CC2538 ROM User's guide (http://www.ti.com/lit/swru333)
//
#define SBL_CC2538_PAGE_ERASE_SIZE 2048
#define SBL_CC2538_FLASH_START_ADDRESS 0x00200000
#define SBL_CC2538_RAM_START_ADDRESS 0x20000000
#define SBL_CC2538_ACCESS_WIDTH_4B 4
#define SBL_CC2538_ACCESS_WIDTH_1B 1
#define SBL_CC2538_PAGE_ERASE_TIME_MS 20
#define SBL_CC2538_MAX_BYTES_PER_TRANSFER 252
#define SBL_CC2538_DIECFG0 0x400D3014
#define SBL_CC2538_BL_CONFIG_PAGE_OFFSET 2007
#define SBL_CC2538_BL_CONFIG_ENABLED_BM 0x10
class SblDeviceCC2538 : public SblDevice
{
public:
SblDeviceCC2538(); // Constructor
~SblDeviceCC2538(); // Destructor
enum {
CMD_PING = 0x20,
CMD_DOWNLOAD = 0x21,
CMD_RUN = 0x22,
CMD_GET_STATUS = 0x23,
CMD_SEND_DATA = 0x24,
CMD_RESET = 0x25,
CMD_ERASE = 0x26,
CMD_CRC32 = 0x27,
CMD_GET_CHIP_ID = 0x28,
CMD_SET_XOSC = 0x29,
CMD_MEMORY_READ = 0x2A,
CMD_MEMORY_WRITE = 0x2B,
};
enum {
CMD_RET_SUCCESS = 0x40,
CMD_RET_UNKNOWN_CMD = 0x41,
CMD_RET_INVALID_CMD = 0x42,
CMD_RET_INVALID_ADR = 0x43,
CMD_RET_FLASH_FAIL = 0x44,
};
protected:
// Virtual functions from SblDevice
uint32_t ping();
uint32_t readStatus(uint32_t *pui32Status);
uint32_t readDeviceId(uint32_t *pui32DeviceId);
uint32_t readFlashSize(uint32_t *pui32FlashSize);
uint32_t readRamSize(uint32_t *pui32RamSize);
uint32_t run(uint32_t ui32Address);
uint32_t reset();
uint32_t eraseFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount);
uint32_t writeFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount, const char *pcData);
uint32_t readMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, uint32_t *pui32Data);
uint32_t readMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, char *pcData);
uint32_t writeMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const uint32_t *pui32Data);
uint32_t writeMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const char *pcData);
uint32_t calculateCrc32(uint32_t ui32StartAddress, uint32_t ui32ByteCount, uint32_t *pui32Crc);
uint32_t sendCmd(uint32_t ui32Cmd, const char *pcSendData = NULL, uint32_t ui32SendLen = 0);
uint32_t addressToPage(uint32_t ui32Address);
bool addressInRam(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1);
bool addressInFlash(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1);
uint32_t setXosc();
private:
uint32_t initCommunication(bool bSetXosc);
uint32_t cmdDownload(uint32_t ui32Address, uint32_t ui32Size);
uint32_t cmdSendData(const char *pcData, uint32_t ui32ByteCount);
uint32_t getBootloaderEnableAddress();
std::string getCmdString(uint32_t ui32Cmd);
std::string getCmdStatusString(uint32_t ui32Status);
};
#endif // __SBL_DEVICE_CC2538_H__

File diff suppressed because it is too large Load Diff

View File

@@ -1,153 +0,0 @@
#ifndef __SBL_DEVICE_CC2650_H__
#define __SBL_DEVICE_CC2650_H__
/******************************************************************************
* Filename: sbl_device_cc2650.h
* Revised: $Date: 2013-07-26 09:53:42 +0200 (fr, 26 jul 2013) $
* Revision: $Revision: 26971 $
*
* Description: Serial Bootloader for CC2650 header file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <sbl_device.h>
#define SBL_CC2650_PAGE_ERASE_SIZE 4096
#define SBL_CC2650_FLASH_START_ADDRESS 0x00000000
#define SBL_CC2650_RAM_START_ADDRESS 0x20000000
#define SBL_CC2650_ACCESS_WIDTH_32B 1
#define SBL_CC2650_ACCESS_WIDTH_8B 0
#define SBL_CC2650_PAGE_ERASE_TIME_MS 20
#define SBL_CC2650_MAX_BYTES_PER_TRANSFER 252
#define SBL_CC2650_MAX_MEMWRITE_BYTES 247
#define SBL_CC2650_MAX_MEMWRITE_WORDS 61
#define SBL_CC2650_MAX_MEMREAD_BYTES 253
#define SBL_CC2650_MAX_MEMREAD_WORDS 63
#define SBL_CC2650_FLASH_SIZE_CFG 0x4003002C
#define SBL_CC2650_RAM_SIZE_CFG 0x40082250
#define SBL_CC2650_BL_CONFIG_PAGE_OFFSET 0xFDB
#define SBL_CC2650_BL_CONFIG_ENABLED_BM 0xC5
#define SBL_CC2650_BL_WORK_MEMORY_START 0x20000000
#define SBL_CC2650_BL_WORK_MEMORY_END 0x2000016F
#define SBL_CC2650_BL_STACK_MEMORY_START 0x20000FC0
#define SBL_CC2650_BL_STACK_MEMORY_END 0x20000FFF
class SblDeviceCC2650 : public SblDevice
{
public:
SblDeviceCC2650(); // Constructor
~SblDeviceCC2650(); // Destructor
enum {
CMD_PING = 0x20,
CMD_DOWNLOAD = 0x21,
CMD_GET_STATUS = 0x23,
CMD_SEND_DATA = 0x24,
CMD_RESET = 0x25,
CMD_SECTOR_ERASE = 0x26,
CMD_CRC32 = 0x27,
CMD_GET_CHIP_ID = 0x28,
CMD_MEMORY_READ = 0x2A,
CMD_MEMORY_WRITE = 0x2B,
CMD_BANK_ERASE = 0x2C,
CMD_SET_CCFG = 0x2D,
};
/* Early samples had different command IDs */
enum
{
REV1_CMD_BANK_ERASE = 0x2A,
REV1_CMD_SET_CCFG = 0x2B,
REV1_CMD_MEMORY_READ = 0x2C,
REV1_CMD_MEMORY_WRITE = 0x2D,
};
enum {
CMD_RET_SUCCESS = 0x40,
CMD_RET_UNKNOWN_CMD = 0x41,
CMD_RET_INVALID_CMD = 0x42,
CMD_RET_INVALID_ADR = 0x43,
CMD_RET_FLASH_FAIL = 0x44,
};
protected:
// Virtual functions from SblDevice
uint32_t ping();
uint32_t readStatus(uint32_t *pui32Status);
uint32_t readDeviceId(uint32_t *pui32DeviceId);
virtual uint32_t readFlashSize(uint32_t *pui32FlashSize);
virtual uint32_t readRamSize(uint32_t *pui32RamSize);
uint32_t reset();
uint32_t eraseFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount);
uint32_t writeFlashRange(uint32_t ui32StartAddress, uint32_t ui32ByteCount, const char *pcData);
uint32_t readMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, uint32_t *pui32Data);
uint32_t readMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, char *pcData);
uint32_t writeMemory32(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const uint32_t *pui32Data);
uint32_t writeMemory8(uint32_t ui32StartAddress, uint32_t ui32UnitCount, const char *pcData);
uint32_t calculateCrc32(uint32_t ui32StartAddress, uint32_t ui32ByteCount, uint32_t *pui32Crc);
uint32_t sendCmd(uint32_t ui32Cmd, const char *pcSendData = NULL, uint32_t ui32SendLen = 0);
std::string getCmdString(uint32_t ui32Cmd);
uint32_t addressToPage(uint32_t ui32Address);
bool addressInRam(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1);
bool addressInFlash(uint32_t ui32StartAddress, uint32_t ui32ByteCount = 1);
uint32_t convertCmdForEarlySamples(uint32_t ui32Cmd);
virtual uint32_t getBootloaderEnableAddress();
// CC2650 specific
uint32_t eraseFlashBank();
uint32_t setCCFG(uint32_t ui32Field, uint32_t ui32FieldValue);
// Device revision. Used internally by SBL to handle early samples with different command IDs.
uint32_t m_deviceRev;
private:
uint32_t initCommunication(bool bSetXosc);
uint32_t cmdDownload(uint32_t ui32Address, uint32_t ui32Size);
uint32_t cmdSendData(const char *pcData, uint32_t ui32ByteCount);
std::string getCmdStatusString(uint32_t ui32Status);
bool addressInBLWorkMemory(uint32_t ui32StartAddr, uint32_t ui32ByteCount = 1);
};
#endif // __SBL_DEVICE_CC2650_H__

View File

@@ -1,330 +0,0 @@
/******************************************************************************
* Filename: sbl_device_cc2652.cpp
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader device file for CC13x2/CC26x2
*
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <sbllib.h>
#include "sbl_device.h"
#include "sbl_device_cc2652.h"
#include "serialib.h"
//-----------------------------------------------------------------------------
/** \brief Constructor
*/
//-----------------------------------------------------------------------------
SblDeviceCC2652::SblDeviceCC2652() : SblDeviceCC2650()
{
DEBUG_PRINT("\n");
m_pageEraseSize = SBL_CC2652_PAGE_ERASE_SIZE;
}
//-----------------------------------------------------------------------------
/** \brief Destructor
*/
//-----------------------------------------------------------------------------
SblDeviceCC2652::~SblDeviceCC2652()
{
DEBUG_PRINT("\n");
}
//-----------------------------------------------------------------------------
/** \brief This function reads device FLASH size in bytes.
*
* \param[out] pui32FlashSize
* Pointer to where FLASH size is stored.
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDeviceCC2652::readFlashSize(uint32_t *pui32FlashSize)
{
DEBUG_PRINT("\n");
uint32_t retCode = SBL_SUCCESS;
//
// Read CC2652 DIECFG0 (contains FLASH size information)
//
uint32_t addr = SBL_CC2652_FLASH_SIZE_CFG;
uint32_t value;
if ((retCode = readMemory32(addr, 1, &value)) != SBL_SUCCESS)
{
setState((tSblStatus)retCode, "Failed to read device FLASH size: %s", getLastError().c_str());
return retCode;
}
//
// Calculate flash size (The number of flash sectors are at bits [7:0])
//
value &= 0xFF;
*pui32FlashSize = value*SBL_CC2652_PAGE_ERASE_SIZE;
m_flashSize = *pui32FlashSize;
return SBL_SUCCESS;
}
//-----------------------------------------------------------------------------
/** \brief This function reads device RAM size in bytes.
*
* \param[out] pui32RamSize
* Pointer to where RAM size is stored.
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDeviceCC2652::readRamSize(uint32_t *pui32RamSize)
{
DEBUG_PRINT("\n");
int retCode = SBL_SUCCESS;
uint32_t addr = SBL_CC2652_RAM_SIZE_CFG;
uint32_t value;
if ((retCode = readMemory32(addr, 1, &value)) != SBL_SUCCESS)
{
setState(retCode, "Failed to read device RAM size: %s", getLastError().c_str());
return retCode;
}
uint32_t ramSizeInfo = (value & CHIP_SRAM_SIZE_INFO_M) >> CHIP_SRAM_SIZE_INFO_S;
m_ramSize = calculateRamSize(ramSizeInfo);
if (*pui32RamSize != NULL)
{
*pui32RamSize = m_ramSize;
}
return retCode;
}
//-----------------------------------------------------------------------------
/** \brief Calculate RAM size.
*
* \param[in] ramSizeInfo
* Register value for RAM size configuration (TOP:PRCM:RAMHWOPT).
* The argument is optional and the default value is 3 (RAM size 80 KB)
* \returns uint32_t
* Ram size
*/
//-----------------------------------------------------------------------------
uint32_t SblDeviceCC2652::calculateRamSize(uint32_t ramSizeInfo)
{
DEBUG_PRINT("\n");
uint32_t ramSize;
switch (ramSizeInfo)
{
case 0:
ramSize = (32 * 1024);
break;
case 1:
ramSize = (48 * 1024);
break;
case 2:
ramSize = (64 * 1024);
break;
case 3:
default:
ramSize = (80 * 1024);
break;
}
return ramSize;
}
//-----------------------------------------------------------------------------
/** \brief This function returns the FLASH address of the bootloader enable
* configuration.
*
* \return
* Returns true if the address/range is within the device RAM.
*/
//-----------------------------------------------------------------------------
uint32_t SblDeviceCC2652::getBootloaderEnableAddress()
{
DEBUG_PRINT("\n");
return SBL_CC2652_FLASH_START_ADDRESS + getFlashSize() - getPageEraseSize() + SBL_CC2652_BL_CONFIG_PAGE_OFFSET;
}
//-----------------------------------------------------------------------------
/** \brief This function returns a string with the device command name of
* \e ui32Cmd.
*
* \param[out] ui32Cmd
* The serial bootloader command.
* \return
* Returns std::string with name of device command.
*/
//-----------------------------------------------------------------------------
std::string
SblDeviceCC2652::getCmdString(uint32_t ui32Cmd)
{
DEBUG_PRINT("\n");
std::string cmd = SblDeviceCC2650::getCmdString(ui32Cmd);
if (cmd.find("Unknown") != std::string::npos)
{
switch (ui32Cmd)
{
case SblDeviceCC2652::CMD_DOWNLOAD_CRC: cmd = "CMD_DOWNLOAD_CRC"; break;
default: cmd = "Unknown command"; break;
}
}
return cmd;
}
//-----------------------------------------------------------------------------
/** \brief This function sends the CC2652 download CRC command and handles the
* device response.
*
* \param[in] ui32Address
* The start address in CC2652 flash.
* \param[in] ui32Size
* Number of bytes to be sent.
* \param[in] ui32Crc
* Total number of bytes to be programmed.
*
* \return
* Returns SBL_SUCCESS if command and response was successful.
*/
//-----------------------------------------------------------------------------
uint32_t SblDeviceCC2652::cmdDownloadCrc(uint32_t ui32Address, uint32_t ui32Size, uint32_t ui32Crc)
{
DEBUG_PRINT("\n");
int retCode = SBL_SUCCESS;
bool bSuccess = false;
//
// Check input arguments
//
if (!addressInFlash(ui32Address, ui32Size) &&
!addressInRam(ui32Address, ui32Size))
{
setState(SBL_ARGUMENT_ERROR, "Specified address range (0x%08X + %d bytes) is not in device FLASH nor RAM.\n", ui32Address, ui32Size);
return SBL_ARGUMENT_ERROR;
}
//
// Generate payload
// - 4B Program address
// - 4B Program data
// - 4B CRC
//
char pcPayload[12];
ulToCharArray(ui32Address, &pcPayload[0]);
ulToCharArray(ui32Size, &pcPayload[4]);
ulToCharArray(ui32Crc, &pcPayload[8]);
//
// Send command
//
if ((retCode = sendCmd(SblDeviceCC2652::CMD_DOWNLOAD_CRC, pcPayload, 12) != SBL_SUCCESS))
{
return retCode;
}
//
// Receive command response (ACK/NAK)
//
if ((retCode = getCmdResponse(bSuccess)) != SBL_SUCCESS)
{
return retCode;
}
//
// Return command response
//
return (bSuccess) ? SBL_SUCCESS : SBL_ERROR;
}
//-----------------------------------------------------------------------------
/** \brief Send command.
*
* \param[in] ui32Cmd
* The command to send.
* \param[in] pcSendData
* Pointer to the data to send with the command.
* \param[in] ui32SendLen
* The number of bytes to send from \e pcSendData.
* \return
* Returns SBL_SUCCESS, ...
*/
//-----------------------------------------------------------------------------
uint32_t
SblDeviceCC2652::sendCmd(uint32_t ui32Cmd, const char *pcSendData/* = NULL*/,
uint32_t ui32SendLen/* = 0*/)
{
DEBUG_PRINT("\n");
unsigned char pktLen = ui32SendLen + 3; // +3 => <1B Length>, <1B checksum>, <1B cmd>
std::vector<char> pvPkt((pktLen));
unsigned char pktSum = generateCheckSum(ui32Cmd, pcSendData, ui32SendLen);
//
// Build packet
//
pvPkt.at(0) = pktLen;
pvPkt.at(1) = pktSum;
pvPkt.at(2) = (unsigned char)ui32Cmd;
if (ui32SendLen)
{
memcpy(&pvPkt[3], pcSendData, ui32SendLen);
}
//
// Send packet
//
if (m_pCom->writeBytes(&pvPkt[0], pvPkt.size()) < 1)
{
setState(SBL_PORT_ERROR, "\nWriting to device failed (Command 0x%04x:'%s').\n", ui32Cmd,getCmdString(ui32Cmd).c_str());
return SBL_PORT_ERROR;
}
//
// Empty and deallocate vector
//
pvPkt.clear();
std::vector<char>().swap(pvPkt);
return SBL_SUCCESS;
}

View File

@@ -1,77 +0,0 @@
#ifndef __SBL_DEVICE_CC2652_H__
#define __SBL_DEVICE_CC2652_H__
/******************************************************************************
* Filename: sbl_device_cc2652.h
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader for CC13x2/CC26x2 header file.
*
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include "sbl_device_cc2650.h"
#define SBL_CC2652_PAGE_ERASE_SIZE 8192
#define SBL_CC2652_FLASH_SIZE_CFG 0x4003002C
#define SBL_CC2652_RAM_SIZE_CFG 0x40082250
#define SBL_CC2652_RAM_SIZE_CFG 0x40082250
#define SBL_CC2652_FLASH_START_ADDRESS SBL_CC2650_FLASH_START_ADDRESS
#define SBL_CC2652_BL_CONFIG_PAGE_OFFSET 0x1FDB
#define CHIP_SRAM_SIZE_INFO 0x40082250
#define CHIP_SRAM_SIZE_INFO_M 0x00000003
#define CHIP_SRAM_SIZE_INFO_S 0
class SblDeviceCC2652 : public SblDeviceCC2650
{
public:
SblDeviceCC2652(); // Constructor
~SblDeviceCC2652(); // Destructor
enum {
CMD_DOWNLOAD_CRC = 0x2F,
};
protected:
uint32_t readFlashSize(uint32_t *pui32FlashSize);
uint32_t readRamSize(uint32_t *pui32RamSize);
uint32_t calculateRamSize(uint32_t ramSizeInfo);
uint32_t getBootloaderEnableAddress();
private:
std::string getCmdString(uint32_t ui32Cmd);
uint32_t sendCmd(uint32_t ui32Cmd, const char *pcSendData = NULL, uint32_t ui32SendLen = 0);
uint32_t cmdDownloadCrc(uint32_t ui32Address, uint32_t ui32Size, uint32_t uiCrc);
};
#endif // __SBL_DEVICE_CC2652_H__

View File

@@ -1,66 +0,0 @@
#ifndef __SBL_EB_INFO_H__
#define __SBL_EB_INFO_H__
/******************************************************************************
* Filename: sbl_eb_info.h
* Revised: $Date: 2013-07-09 15:06:47 +0200 (Tue, 09 Jul 2013) $
* Revision: $Revision: 26800 $
*
* Description: Serial Bootloader EB info class header file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <string.h>
class SblEbInfo
{
public:
enum
{
DEVICE_NAME_SIZE = 15,
EB_PORT_SIZE = 16,
DESCRIPTION_SIZE = 256
};
char ebPort[EB_PORT_SIZE]; // E.g. COM42
char ebDescription[DESCRIPTION_SIZE];
char devName[DEVICE_NAME_SIZE]; // E.g. CC2538 for CC2650
SblEbInfo& operator = (const SblEbInfo& other) {
strncpy(ebPort, other.ebPort, EB_PORT_SIZE);
strncpy(ebDescription, other.ebDescription, DESCRIPTION_SIZE);
strncpy(devName, other.devName, DEVICE_NAME_SIZE);
return *this;
}
};
#endif // __SBL_EB_INFO_H__

View File

@@ -1,39 +0,0 @@
/******************************************************************************
* Filename: sbllib.cpp
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader Library main file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/

View File

@@ -1,69 +0,0 @@
#ifndef __SBLLIB_H__
#define __SBLLIB_H__
/******************************************************************************
* Filename: sbllib.h
* Revised: $Date$
* Revision: $Revision$
*
* Description: Serial Bootloader Library header file.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#include <string>
#include <stdint.h>
#include "debug.h"
#define SBL_MAX_DEVICES 20
#define SBL_DEFAULT_RETRY_COUNT 1
#define SBL_DEFAULT_READ_TIMEOUT 100 // in ms
#define SBL_DEFAULT_WRITE_TIMEOUT 200 // in ms
typedef enum {
SBL_SUCCESS = 0,
SBL_ERROR,
SBL_ARGUMENT_ERROR,
SBL_TIMEOUT_ERROR,
SBL_PORT_ERROR,
SBL_ENUM_ERROR,
SBL_UNSUPPORTED_FUNCTION,
} tSblStatus;
#include "serialib.h"
#include "sbl_device.h"
#include "sbl_device_cc2538.h"
#include "sbl_device_cc2650.h"
#include "sbl_device_cc2652.h"
#include "sbl_eb_info.h"
#endif // __SBLLIB_H__

File diff suppressed because it is too large Load Diff

View File

@@ -1,220 +0,0 @@
/*!
\file serialib.h
\brief Header file of the class serialib. This class is used for communication over a serial device.
\author Philippe Lucidarme (University of Angers)
\version 2.0
\date december the 27th of 2019
This Serial library is used to communicate through serial port.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This is a licence-free software, it can be used by anyone who try to build a better world.
*/
#ifndef SERIALIB_H
#define SERIALIB_H
// Used for TimeOut operations
#include <sys/time.h>
// Include for windows
#if defined (_WIN32) || defined (_WIN64)
// Accessing to the serial port under Windows
#include <windows.h>
#endif
// Include for Linux
#ifdef __linux__
#include <stdlib.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <termios.h>
#include <string.h>
#include <iostream>
// File control definitions
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <vector>
#endif
/*! To avoid unused parameters */
#define UNUSED(x) (void)(x)
/*! \class serialib
\brief This class is used for communication over a serial device.
*/
class serialib
{
public:
//_____________________________________
// ::: Constructors and destructors :::
// Constructor of the class
serialib ();
// Destructor
~serialib ();
//_________________________________________
// ::: Configuration and initialization :::
// Open a device
char openDevice (const char *Device,const unsigned int Bauds);
// Close the current device
void closeDevice();
//___________________________________________
// ::: Read/Write operation on characters :::
// Write a char
char writeChar (char);
// Read a char (with timeout)
char readChar (char *pByte,const unsigned int timeOut_ms=0);
//________________________________________
// ::: Read/Write operation on strings :::
// Write a string
char writeString (const char *String);
// Read a string (with timeout)
int readString ( char *receivedString,
char finalChar,
unsigned int maxNbBytes,
const unsigned int timeOut_ms=0);
// _____________________________________
// ::: Read/Write operation on bytes :::
// Write an array of bytes
int writeBytes (const void *Buffer, const unsigned int NbBytes);
// Read an array of byte (with timeout)
int readBytes (void *buffer,unsigned int maxNbBytes,const unsigned int timeOut_ms=100, unsigned int sleepDuration_us=100);
// _________________________
// ::: Special operation :::
// Empty the received buffer
char flushReceiver();
// Return the number of bytes in the received buffer
int available();
// _________________________
// ::: Access to IO bits :::
// Set CTR status (Data Terminal Ready, pin 4)
bool DTR(bool status);
bool setDTR();
bool clearDTR();
// Set RTS status (Request To Send, pin 7)
bool RTS(bool status);
bool setRTS();
bool clearRTS();
// Get RI status (Ring Indicator, pin 9)
bool isRI();
// Get DCD status (Data Carrier Detect, pin 1)
bool isDCD();
// Get CTS status (Clear To Send, pin 8)
bool isCTS();
// Get DSR status (Data Set Ready, pin 9)
bool isDSR();
// Get RTS status (Request To Send, pin 7)
bool isRTS();
// Get CTR status (Data Terminal Ready, pin 4)
bool isDTR();
private:
// Read a string (no timeout)
int readStringNoTimeOut (char *String,char FinalChar,unsigned int MaxNbBytes);
// Current DTR and RTS state (can't be read on WIndows)
bool currentStateRTS;
bool currentStateDTR;
#if defined (_WIN32) || defined( _WIN64)
// Handle on serial device
HANDLE hSerial;
// For setting serial port timeouts
COMMTIMEOUTS timeouts;
#endif
#ifdef __linux__
int fd;
#endif
};
/*! \class timeOut
\brief This class can manage a timer which is used as a timeout.
*/
// Class timeOut
class timeOut
{
public:
// Constructor
timeOut();
// Init the timer
void initTimer();
// Return the elapsed time since initialization
unsigned long int elapsedTime_ms();
private:
// Used to store the previous time (for computing timeout)
struct timeval previousTime;
};
#endif // serialib_H

View File

@@ -1,162 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bluez
PKG_VERSION:=5.37
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/bluetooth/
PKG_MD5SUM:=33177e5743e24b2b3738f72be64e3ffb
PKG_LICENSE:=GPL-2.0+
PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=Nicolas Thill <nico@openwrt.org>
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
define Package/bluez/Default
TITLE:=Bluetooth
URL:=http://www.bluez.org/
endef
define Package/bluez-examples
$(call Package/bluez/Default)
SECTION:=utils
CATEGORY:=Utilities
TITLE+= python example apps
DEPENDS:=
endef
define Package/bluez-examples/description
contains many examples apps for bluetooth, requiring python
endef
define Package/bluez-libs
$(call Package/bluez/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE+= library
DEPENDS:=+libpthread +kmod-bluetooth
endef
define Package/bluez-utils
$(call Package/bluez/Default)
SECTION:=utils
CATEGORY:=Utilities
TITLE+= utilities
DEPENDS:=+bluez-libs +libpthread +librt +glib2 +libncurses +libreadline $(INTL_DEPENDS) $(ICONV_DEPENDS)
endef
define Package/bluez-daemon
$(call Package/bluez/Default)
SECTION:=utils
CATEGORY:=Utilities
TITLE+= daemon
DEPENDS:=+bluez-libs +bluez-utils +dbus +libical $(INTL_DEPENDS) $(ICONV_DEPENDS)
endef
define Package/bluez-daemon/conffiles
/etc/bluetooth/main.conf
/etc/bluetooth/network.conf
/etc/bluetooth/input.conf
/etc/bluetooth/proximity.conf
/etc/config/bluetooth
endef
CONFIGURE_ARGS += \
--enable-static \
--enable-shared \
--enable-client \
--enable-datafiles \
--enable-experimental \
--enable-library \
--enable-monitor \
--enable-obex \
--enable-threads \
--enable-tools \
--disable-android \
--disable-cups \
--disable-manpages \
--disable-sixaxis \
--disable-systemd \
--disable-test \
--disable-udev \
TARGET_CPPFLAGS += \
-D_GNU_SOURCE
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/bluetooth $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbluetooth.{a,so*} $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/bluez.pc $(1)/usr/lib/pkgconfig/
endef
define Package/bluez-examples/install
$(INSTALL_DIR) $(1)/usr/bin/bluez
$(INSTALL_DATA) $(PKG_BUILD_DIR)/test/* $(1)/usr/bin/bluez/
endef
define Package/bluez-libs/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbluetooth.so.* $(1)/usr/lib/
endef
define Package/bluez-utils/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/bin/bccmd $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/bluemoon $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/btmon $(1)/usr/bin/
$(CP) $(PKG_BUILD_DIR)/tools/btmgmt $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/ciptool $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/hciattach $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/hciconfig $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/hcidump $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/hcitool $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/hex2hcd $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/l2ping $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/l2test $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/rctest $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/rfcomm $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/sdptool $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/attrib/gatttool $(1)/usr/bin/
endef
define Package/bluez-daemon/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/lib/bluetooth/bluetoothd $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/bluetoothctl $(1)/usr/bin/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/bluetooth/obexd $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/bluetooth.config $(1)/etc/config/bluetooth
$(INSTALL_DIR) $(1)/etc/dbus-1/system.d/
$(INSTALL_DATA) ./files/bluetooth.dbus $(1)/etc/dbus-1/system.d/bluetooth.conf
$(INSTALL_DIR) $(1)/etc/bluetooth
$(INSTALL_DATA) $(PKG_BUILD_DIR)/src/main.conf $(1)/etc/bluetooth/main.conf
$(INSTALL_DATA) $(PKG_BUILD_DIR)/profiles/network/network.conf $(1)/etc/bluetooth/network.conf
$(INSTALL_DATA) $(PKG_BUILD_DIR)/profiles/input/input.conf $(1)/etc/bluetooth/input.conf
$(INSTALL_DATA) $(PKG_BUILD_DIR)/profiles/proximity/proximity.conf $(1)/etc/bluetooth/proximity.conf
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/bluetoothd.init $(1)/etc/init.d/bluetoothd
$(INSTALL_BIN) ./files/bluez-bccmd.init $(1)/etc/init.d/bluez-bccmd
$(INSTALL_DIR) $(1)/etc/bluetooth
$(INSTALL_DATA) ./files/csr8x11-a12-bt4.2-patch.psr $(1)/etc/bluetooth/
$(INSTALL_DATA) ./files/csr8x11-coex.psr $(1)/etc/bluetooth/
endef
$(eval $(call BuildPackage,bluez-examples))
$(eval $(call BuildPackage,bluez-libs))
$(eval $(call BuildPackage,bluez-utils))
$(eval $(call BuildPackage,bluez-daemon))

View File

@@ -1,15 +0,0 @@
config bluetoothd
# option config /etc/bluetooth/main.conf
option enabled 1
config hciattach
option initspeed 115200
option tty ttyS1
option type csr
option speed 115200
option flow noflow
option enabled 0
config rfcomm
# option config /etc/bluetooth/rfcomm.conf
option enabled 0

View File

@@ -1,37 +0,0 @@
<!-- This configuration file specifies the required security policies
for Bluetooth core daemon to work. -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy user="root">
<allow own="org.bluez"/>
</policy>
<policy at_console="true">
<allow send_path="/"/>
<allow send_path="/org/bluez"/>
<allow send_destination="org.bluez.Manager"/>
<allow receive_sender="org.bluez.Manager"/>
<allow send_destination="org.bluez.Adapter"/>
<allow receive_sender="org.bluez.Adapter"/>
<allow send_destination="org.bluez.Device"/>
<allow receive_sender="org.bluez.Device"/>
<allow send_destination="org.bluez.Service"/>
<allow receive_sender="org.bluez.Service"/>
<allow send_destination="org.bluez.Database"/>
<allow receive_sender="org.bluez.Database"/>
<allow send_destination="org.bluez.Security"/>
<allow receive_sender="org.bluez.Security"/>
</policy>
</busconfig>

View File

@@ -1,13 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
#start after dbus (60)
START=62
USE_PROCD=1
PROG=/usr/bin/bluetoothd
start_service() {
procd_open_instance
procd_set_param command "$PROG" -n
procd_close_instance
}

View File

@@ -1,43 +0,0 @@
#!/bin/sh /etc/rc.common
. /lib/ar71xx.sh
START=63
bt_up(){
hciconfig hci0 up
count=5
while [ $count -gt 0 ]
do
if hciconfig hci0 lestates >/dev/null; then
break;
fi
let count=$count-1
sleep 1
done
if [ $count -eq 0 ];then
echo "Failed to enable hci0" >> /tmp/log/bccmd
fi
}
bccmd_init_csr8x11() {
bt_up
bccmd -t hci -d hci0 psload /etc/bluetooth/csr8x11-a12-bt4.2-patch.psr
bccmd -t hci -d hci0 psload /etc/bluetooth/csr8x11-coex.psr
bccmd -t hci -d hci0 warmreset
bt_up
}
start() {
board_name=$(ar71xx_board_name)
case "$board_name" in
cus531mp3|\
cus531mp3-dual|\
cus531mp3-nand)
bccmd_init_csr8x11
;;
esac
}

View File

@@ -1,50 +0,0 @@
// explicit, PSKEY_HCI_LMP_LOCAL_VERSION (0x010d, 269), 1 words
&010d = 0808
// explicit, PSKEY_LMP_REMOTE_VERSION (0x010e, 270), 1 words
&010e = 0008
// patch_hardware_0, PSKEY_PATCH50 (0x212c, 8492), 56 words
&212c = 0000 f001 0617 0513 0118 ff2b ff0e 1a00 2818 009e 081b f100 8888 24f0 f925 f821 0a17 0184 0cf0 0117 0013 0009 02a4 fb25 fa21 f915 f811 fb55 fa61 09e0 ff84 10f0 0117 0013 0009 02a4 f935 f841 f925 f821 0f1b 0712 10a4 0494 0712 e151 0722 f915 f811 0018 ff2b ff0e f000 0518 00e2 5a79
// patch_hardware_1, PSKEY_PATCH51 (0x212d, 8493), 21 words
&212d = 0002 968a 0863 f925 f821 0757 0663 e099 02ec 05e0 f915 0727 f815 0627 0218 ff2b ff0e 9700 8d18 00e2 7e34
// patch_hardware_2, PSKEY_PATCH52 (0x212e, 8494), 16 words
&212e = 0002 0b5a 0100 7834 0040 0327 0223 f815 e311 0218 ff2b ff0e 0b00 5e18 00e2 59c1
// patch_hardware_3, PSKEY_PATCH53 (0x212f, 8495), 17 words
&212f = 0000 7315 0084 04f0 0800 0014 03e0 f800 1215 0b27 0018 ff2b ff0e 7300 1818 00e2 0549
// patch_hardware_4, PSKEY_PATCH54 (0x2130, 8496), 21 words
&2130 = 0001 53f8 0817 0e27 0c00 6384 07f0 0118 ff2b ff0e 5400 0918 00e2 0917 0118 ff2b ff0e 5400 fb18 00e2 91f6
// patch_hardware_5, PSKEY_PATCH55 (0x2131, 8497), 49 words
&2131 = 0002 c0d5 0423 05f4 031b 0012 0280 1df0 021b 0916 1000 00c4 1ef0 0916 03c4 1bf4 031b 0012 0280 17f4 0380 15f4 0480 13f4 0580 11f4 0680 0ff4 0b80 0df4 0d80 0bf4 019c fb00 6719 0d9e 0218 ff2b ff0e c200 8c18 00e2 0218 ff2b ff0e c100 de18 00e2 c5cf
// patch_hardware_6, PSKEY_PATCH56 (0x2132, 8498), 42 words
&2132 = 0003 243f f40b 0827 0923 e019 0916 01b4 0926 0318 ff2b ff0e 2400 4218 00e2 fa0b 3d14 0327 0114 0227 0014 0127 0027 081b 0816 0218 ff2b ff0e f700 fd18 009e e111 081b 0816 0218 ff2b ff0e 3300 ff18 009e fa0f 40f2
// patch_hardware_7, PSKEY_PATCH57 (0x2133, 8499), 23 words
&2133 = 0003 254e 02c0 0916 1000 00c4 02f4 02b0 0916 fec4 e1b1 0922 0816 0318 ff2b ff0e 2500 5218 8000 00c0 08f2 00e2 e402
// patch_hardware_8, PSKEY_PATCH58 (0x2134, 8500), 16 words
&2134 = 0003 21ca fa0b 0227 0323 e019 0916 01b4 0926 0318 ff2b ff0e 2200 cd18 00e2 22dc
// patch_hardware_9, PSKEY_PATCH59 (0x2135, 8501), 18 words
&2135 = 0000 55e2 09f4 0218 ff2b ff0e 2c00 a718 009e 0314 fc0f 0018 ff2b ff0e 5600 0118 00e2 a008
// patch_hardware_10, PSKEY_PATCH60 (0x2136, 8502), 30 words
&2136 = 0004 0d80 1aa4 0418 ff2b ff0e 1d00 ba18 009e 0184 0d2c 0013 8f00 89d0 0117 bf00 d6d4 0318 ff2b ff0e 2700 4218 009e 0418 ff2b ff0e 0e00 8418 00e2 6855
// patch_hardware_11, PSKEY_PATCH61 (0x2137, 8503), 22 words
&2137 = 0002 4da5 0118 ff2b ff0e 6200 c518 009e 031b 2b22 fcc4 2c26 0114 e700 f025 0218 ff2b ff0e 4e00 a818 00e2 8dfc
// patch_sched_get_or_peek_message, PSKEY_PATCH123 (0x220b, 8715), 49 words
&220b = fa0b 0717 0484 2cf0 0617 0690 e119 0c00 d438 041a 001a 022b 23f4 0116 0184 20f0 0216 0327 1df4 e119 0016 0784 19f0 e500 ab15 8000 0054 0100 c018 ff2b fe27 0317 ff0e fe9f e199 0cf4 7d00 f214 0127 0014 0027 0317 000e 019f 0014 021b 0226 fa0f 8392
// patch_spare1, PSKEY_PATCH155 (0x222b, 8747), 60 words
&222b = e70b 1627 a100 8514 0227 0214 0127 6b00 d814 0427 0214 0327 0417 fe27 0317 ff27 1613 0230 0814 0027 e415 0534 ff0e fe9f 0513 0009 01a4 e015 7fc4 7f84 1bf0 0617 1584 18f0 161b 0116 010e 029f e119 049a 11f4 0116 4184 0ef0 e500 ac11 8000 0050 0100 c014 ff27 fe23 0816 ff0e fe9f 0114 02e0 0014 e70f 4d65
// patch_spare2, PSKEY_PATCH156 (0x222c, 8748), 40 words
&222c = f40b 0927 2900 d414 0427 0314 0327 3500 ea14 0627 0314 0527 2900 9614 0827 0414 0727 0917 0110 070e 089f 0917 030e 049f 0617 fe27 0517 ff27 7f14 0027 1514 0127 2a14 0227 0114 0913 ff0e fe9f f40f 3478

View File

@@ -1,38 +0,0 @@
// Set the crystal frequency to 26MHz
&01fe = 6590
// PSKEY_COEX_SCHEME
// 7 = Use Unity-e.
&2480 = 0007
// Signal Configuration
// --------------------
// PSKEY_COEX_PIO_UNITY_3_BT_ACTIVE
// BT_ACTIVE (PIO=0, polarity=active high)
&2483 = 0000 0001
// PSKEY_COEX_PIO_UNITY_3_BT_STATUS
// BT_STATUS (PIO=5, polarity=active high)
&2484 = 0005 0001
// PSKEY_COEX_PIO_UNITY_3_WLAN_DENY
// WLAN_DENY (PIO=1, polarity=active high)
&2485 = 0001 0001
// Priority Configuration
// ----------------------
// PSKEY_coex_transaction_priority_table
&2488 = 0000 0000 0000 0000 0000 0001 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001
// PSKEY_COEX_BLE_TRANSACTION_PRIORITY_TABLE
&2493 = 0000 0000 0000 0000 0000 0000 0000 0000 0001 0001 0001 0000 0000 0000 0000 0001
// PSKEY_COEX_UNITY_EXPRESS_TIMINGS
// BT_ACTIVE lead time - 20 us
// BT_STATUS lead time - 12 us
&248a = 0014 000c
//Disable clock request on PIO2
&0246 = 0000

View File

@@ -1,14 +0,0 @@
#!/bin/sh
# Write bluetooth PIN number here:
pin=
if [ -z "$pin" ]; then
msg="Set bluetooth PIN in file $0"
logger -p user.err "$msg"
for i in /dev/pts/* ; do
[ -w $i ] && echo "$msg" > $i
done
else
echo "PIN:$pin"
fi

View File

@@ -1,40 +0,0 @@
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -101,20 +101,37 @@ int uart_speed(int s)
return B230400;
case 460800:
return B460800;
+/* FIX: Not all platform support this high serial speed
+ claudyus84 @gamil.com
+*/
+#ifdef B500000
case 500000:
return B500000;
+#endif
+#ifdef B576000
case 576000:
return B576000;
+#endif
+#ifdef B921600
case 921600:
return B921600;
+#endif
+#ifdef B1000000
case 1000000:
return B1000000;
+#endif
+#ifdef B1152000
case 1152000:
return B1152000;
+#endif
+#ifdef B1500000
case 1500000:
return B1500000;
+#endif
+#ifdef B2000000
case 2000000:
return B2000000;
+#endif
#ifdef B2500000
case 2500000:
return B2500000;

View File

@@ -1,48 +0,0 @@
--- a/Makefile.in
+++ b/Makefile.in
@@ -2441,7 +2441,7 @@ unit_tests = $(am__append_35) unit/test-
@CLIENT_TRUE@ monitor/uuid.h monitor/uuid.c
@CLIENT_TRUE@client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ @DBUS_LIBS@ \
-@CLIENT_TRUE@ -lreadline
+@CLIENT_TRUE@ -lreadline -lncurses
@MONITOR_TRUE@monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
@MONITOR_TRUE@ monitor/display.h monitor/display.c \
@@ -2691,13 +2691,13 @@ unit_tests = $(am__append_35) unit/test-
@READLINE_TRUE@ client/display.h
@READLINE_TRUE@attrib_gatttool_LDADD = lib/libbluetooth-internal.la \
-@READLINE_TRUE@ src/libshared-glib.la @GLIB_LIBS@ -lreadline
+@READLINE_TRUE@ src/libshared-glib.la @GLIB_LIBS@ -lreadline -lncurses
@READLINE_TRUE@tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
@READLINE_TRUE@ tools/obex-client-tool.c
@READLINE_TRUE@tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
-@READLINE_TRUE@ @GLIB_LIBS@ -lreadline
+@READLINE_TRUE@ @GLIB_LIBS@ -lreadline -lncurses
@READLINE_TRUE@tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
@READLINE_TRUE@ tools/obex-server-tool.c
@@ -2707,17 +2707,17 @@ unit_tests = $(am__append_35) unit/test-
@READLINE_TRUE@ client/display.h client/display.c
@READLINE_TRUE@tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
-@READLINE_TRUE@ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline
+@READLINE_TRUE@ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
@READLINE_TRUE@tools_obexctl_SOURCES = tools/obexctl.c \
@READLINE_TRUE@ client/display.h client/display.c
@READLINE_TRUE@tools_obexctl_LDADD = gdbus/libgdbus-internal.la \
-@READLINE_TRUE@ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline
+@READLINE_TRUE@ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
@READLINE_TRUE@tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c
@READLINE_TRUE@tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-mainloop.la \
-@READLINE_TRUE@ -lreadline
+@READLINE_TRUE@ -lreadline -lncurses
@EXPERIMENTAL_TRUE@tools_gatt_service_SOURCES = tools/gatt-service.c
@EXPERIMENTAL_TRUE@tools_gatt_service_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ gdbus/libgdbus-internal.la

View File

@@ -1,14 +0,0 @@
--- a/profiles/audio/a2dp-codecs.h
+++ b/profiles/audio/a2dp-codecs.h
@@ -234,6 +234,11 @@ typedef struct {
uint8_t channel_mode:4;
} __attribute__ ((packed)) a2dp_aptx_t;
+typedef struct {
+ a2dp_vendor_codec_t info;
+ uint8_t unknown[2];
+} __attribute__ ((packed)) a2dp_ldac_t;
+
#else
#error "Unknown byte order"
#endif

View File

@@ -1,14 +0,0 @@
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -48,7 +48,7 @@
#define CSR_STORES_PSF (0x0002)
#define CSR_STORES_PSROM (0x0004)
#define CSR_STORES_PSRAM (0x0008)
-#define CSR_STORES_DEFAULT (CSR_STORES_PSI | CSR_STORES_PSF)
+#define CSR_STORES_DEFAULT 0
#define CSR_TYPE_NULL 0
#define CSR_TYPE_COMPLEX 1
--
2.1.4

View File

@@ -1,93 +0,0 @@
diff --git a/tools/bccmd.c b/tools/bccmd.c
old mode 100644
new mode 100755
index 6bc28da..1605d1c
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -636,6 +636,78 @@ static int opt_pskey(int argc, char *argv[], uint16_t *stores, int *reset, int *
return optind;
}
+int inline serialize_u32(uint8_t *array, uint32_t val32)
+{
+ if (NULL == array)
+ return -1;
+
+ array[0] = (val32 & 0xff0000) >> 16;
+ array[1] = val32 >> 24;
+ array[2] = val32 & 0xff;
+ array[3] = (val32 & 0xff00) >> 8;
+
+ return 0;
+}
+
+int inline deserialize_u32(uint8_t *array, uint32_t *pval32)
+{
+ if (NULL == array || NULL == pval32)
+ return -1;
+
+ *pval32 = (array[1]<<24)
+ | (array[0]<<16)
+ | (array[3]<<8)
+ | array[2];
+ return 0;
+}
+
+static int setpio32(int transport, uint32_t varID, uint32_t mask, uint32_t bits)
+{
+ uint8_t array[32];
+ uint8_t *ptr = NULL;
+ uint32_t result = 0;
+ int err;
+
+ memset(array, 0, sizeof(array));
+ ptr = array;
+
+ serialize_u32(ptr, mask);
+ ptr += 4;
+
+ serialize_u32(ptr, bits);
+
+ err = transport_write(transport, varID, array, 12);
+ if (err < 0)
+ return err;
+
+ deserialize_u32(&array[8], &result);
+ printf("result: 0x%x\n", result);
+
+ return 0;
+
+}
+
+
+static int cmd_pio32set(int transport, int argc, char *argv[])
+{
+ uint32_t varID;
+ uint32_t mask;
+ uint32_t bits;
+
+ argc--;
+ argv++;
+
+ if (3 != argc)
+ return -1;
+
+ varID = strtol(argv[0] + 2, NULL, 16);
+ mask = strtol(argv[1] + 2, NULL, 16);
+ bits = strtol(argv[2] + 2, NULL, 16);
+
+ return setpio32(transport, varID, mask, bits);
+}
+
+
#define OPT_PSKEY(min, max, stores, reset, help) \
opt_pskey(argc, argv, (stores), (reset), (help)); \
argc -= optind; argv += optind; optind = 0; \
@@ -1112,6 +1184,7 @@ static struct {
{ "psread", cmd_psread, NULL, "Read all PS keys" },
{ "psload", cmd_psload, "<file>", "Load all PS keys from PSR file" },
{ "pscheck", cmd_pscheck, "<file>", "Check PSR file" },
+ { "pio32set", cmd_pio32set, "<VarID> <mask> <bits>","Set value for PIO32 register" },
{ "adc", cmd_adc, "<mux>", "Read ADC value of <mux> input" },
{ NULL }
};

View File

@@ -1,50 +0,0 @@
diff --git a/tools/bccmd.c b/tools/bccmd.c
index 1605d1c..5655bb5 100755
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -555,6 +555,37 @@ static int cmd_radiotest(int transport, int argc, char *argv[])
return transport_write(transport, CSR_VARID_RADIOTEST, array, 8);
}
+static int cmd_fullradiotest(int transport, int argc, char *argv[])
+{
+ uint8_t array[8];
+ uint16_t testID;
+ uint16_t word1;
+ uint16_t word2;
+ uint16_t word3;
+
+ OPT_HELP(4, NULL);
+
+ testID = atoi(argv[0]);
+ word1 = atoi(argv[1]);
+ word2 = atoi(argv[2]);
+ word3 = atoi(argv[3]);
+
+ printf("TestID %u, word1 %u, word2 %u, word3 %u\n",
+ testID, word1, word2, word3);
+
+ memset(array, 0, sizeof(array));
+ array[0] = testID & 0xff;
+ array[1] = testID >> 8;
+ array[2] = word1 & 0xff;
+ array[3] = word1 >> 8;
+ array[4] = word2 & 0xff;
+ array[5] = word2 >> 8;
+ array[6] = word3 & 0xff;
+ array[7] = word3 >> 8;
+
+ return transport_write(transport, CSR_VARID_RADIOTEST, array, 8);
+}
+
static int cmd_memtypes(int transport, int argc, char *argv[])
{
uint8_t array[8];
@@ -1176,6 +1207,7 @@ static struct {
{ "hoppingon", cmd_hoppingon, "", "Revert to channel hopping" },
{ "rttxdata1", cmd_rttxdata1, "<freq> <level>", "TXData1 radio test" },
{ "radiotest", cmd_radiotest, "<freq> <level> <id>", "Run radio tests" },
+ { "fullradiotest", cmd_fullradiotest,"<id> <w1> <w2> <w3>", "Run full radio tests" },
{ "memtypes", cmd_memtypes, NULL, "Get memory types" },
{ "psget", cmd_psget, "<key>", "Get value for PS key" },
{ "psset", cmd_psset, "<key> <value>", "Set value for PS key" },

View File

@@ -1,29 +0,0 @@
Index: bluez-5.37/profiles/input/hog.c
===================================================================
--- bluez-5.37.orig/profiles/input/hog.c
+++ bluez-5.37/profiles/input/hog.c
@@ -107,8 +107,13 @@ static struct hog_device *hog_device_new
product, version);
dev = new0(struct hog_device, 1);
- dev->device = btd_device_ref(device);
dev->hog = bt_hog_new_default(name, vendor, product, version, prim);
+ if (!dev->hog) {
+ free(dev);
+ return NULL;
+ }
+
+ dev->device = btd_device_ref(device);
/*
* TODO: Remove attio callback and use .accept once using
@@ -189,6 +194,9 @@ static int hog_probe(struct btd_service
continue;
dev = hog_device_new(device, prim);
+ if (!dev)
+ break;
+
btd_service_set_user_data(service, dev);
return 0;
}

View File

@@ -1,29 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=csr8811
PKG_RELEASE:=1
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
include $(INCLUDE_DIR)/package.mk
define Package/csr8811
SECTION:=utils
CATEGORY:=Utilities
TITLE:=TIP CSR8811 support package
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile/Default
endef
Build/Compile = $(Build/Compile/Default)
define Package/csr8811/install
$(CP) ./files/* $(1)
endef
$(eval $(call BuildPackage,csr8811))

View File

@@ -1,9 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
boot() {
bccmd -t bcsp -b 115200 -d /dev/ttyMSM1 psload -r /lib/firmware/CSR8811/pb-207-csr8x11-rev8.psr
sleep 1
hciattach -s 115200 /dev/ttyMSM1 any 115200
}

View File

@@ -1,320 +0,0 @@
// =============================================================================
//
// Copyright (c) 2015 - 2017 Qualcomm Technologies International, Ltd.
// All Rights Reserved.
// Qualcomm Technologies International, Ltd. Confidential and Proprietary.
// report this in case of problems:
// $Revision: #8 $
// Built Mon Feb 20 11:33:32 2017 GMT
// Checked-in $DateTime: 2017/02/20 11:36:26 $
// $File: //depot/bc/gemini-a12/dev/patches/10520/pb-207.psr $
//
// Patch is for build 10520 gem_5hci_rom_bt4.1_gemA12_1407301204_dspm_encr128
//
// Issues patched: B-158094, B-169261, B-171616, B-174351, B-176411,
// B-179448, B-180762, B-184008, B-206751, B-208678,
// B-216310, B-220605, B-223811
//
// Documentation from pb-207.pb
// ----------------------------
//
// General purpose patch and PSKEY bundle for CSR8811
// and CSR8311 A12 BT4.2 (build ID 10520).
//
// Documentation from pb-173-common.pb
// -----------------------------------
//
// General patch bundle for Gemini-A12 (build ID 10520)
// Patches and keys in here should be common to all
// package variants.
//
// Documentation from report_bt4p2.pb
// ----------------------------------
//
// Issues patched: B-174351
//
// Report BT version 4.2
//
// Documentation from patch_ulp_adv_avg_to_calc.xap
// ------------------------------------------------
//
// Issues patched: B-171616
//
// BlueCore can be configured through BCCMDVARID_BLE_CONFIG_ADV_RSSI_AVG_PARAM
// to report the advertising rssi average through LE ADVERTISING REPORT to the
// host for a given PEER LE device.
// For more information, See CS-317256-AN.
//
// If the BlueCore is unable to receive a LE ADVERTISING REPORT from the PEER
// before a configured average rssi supervision timeout, then the BlueCore
// should send a LE ADVERTISING REPORT with rssi value equal to -127 conveying
// that the PEER is out of the range; however, it fails to do this.
//
// Documentation from patch_ble_scan_deaf.xap
// ------------------------------------------
//
// Issues patched: B-158094
//
// When BlueCore is asked to do BLE scanning, it scans for a window
// approximately 2.5% shorter than asked for. Generally, this does
// not cause noticeable effects; sometimes BLE adverts can be missed
// making connection initialisation between two BLE devices take
// somewhat longer than expected. In pathological cases, especially
// if the scan window is long, connections may fail to be made entirely.
//
// Documentation from patch_usb_suspend_deep_sleep.xap
// ---------------------------------------------------
//
// Issues patched: B-176411
//
// When BlueCore device is bus powered and is in USB suspend mode,
// the current consumption is approximately 8 mA which is higher
// than the expected current of 250 uA
//
// Documentation from patch_tx_if_reduction.xap
// --------------------------------------------
//
// Issues patched: B-169261
//
// When a BlueCore7 device is configured to use a +/-500 kHz transmit IF, this
// can be overridden and a +/-375 kHz IF used instead. This reduces the
// bandwidthof the transmit spectrum providing a greater margin in a Chinese
// regulatory test.
// Only transmit IFs of +/-500 kHz may be reduced; if BlueCore7 is configured to
// use a TX IF of +/-1 MHz IF that will remain unchanged.
//
// Documentation from coex_shutdown.xap
// ------------------------------------
//
// Issues patched: B-208678
//
// With Coexistence Unity-3 scheme, If the WLAN_DENY signal is asserted during
// the initial phase of an adaptive frequency hopping(AFH) scan, the Bluecore
// device fails to deassert its BT_ACTIVE signal
//
// Documentation from patch_access_address.xap
// -------------------------------------------
//
// Issues patched: B-206751
//
// BlueCore devices may generate access addresses that only
// have one bit transition in the 6 most significant bits.
// The problem is seen on access addresses that have the most
// significant bit set to one and only have one bit transition
// in the 6 most significant bits.
//
// Furthermore, the access address, whilst not identical to the
// advertising channel packets Access Address, may differ by
// only one bit.
//
// Documentation from patch_sched_get_or_peek_message.c
// ----------------------------------------------------
//
// Issues patched: B-220605
//
// During the crossover of a locally initiated
// LMP_unsniff_req and peer initiated LMP_sniff_subrate_req,
// Bluecore responds with LMP_Sniff_Subrate_Rsp even if it
// has initiated LMP_unsniff. This probably confuses peer and
// peer stops responding, leading to a timeout.
//
// Documentation from patch_sched_get_or_peek_message_part2.c
// ----------------------------------------------------------
//
// Issues patched: B-220605
//
// During the crossover of a locally initiated
// LMP_unsniff_req and peer initiated LMP_sniff_subrate_req,
// Bluecore responds with LMP_Sniff_Subrate_Rsp even if it
// has initiated LMP_unsniff. This probably confuses peer and
// peer stops responding, leading to a timeout.
//
// Documentation from patch_ble_advt_restart.xap
// ---------------------------------------------
//
// Issues patched: B-223811
//
// When advertisements are disabled before the expiry of the interval
// and enabled immediately the advertisements are not sent before the
// expiry of the advertising interval
//
// Documentation from patch_whitelist_connection_status.xap
// --------------------------------------------------------
//
// Issues patched: B-180762
//
// If a BlueCore device attempts but fails to form a Low Energy (LE) connection
// to a remote slave using the whitelist, it will make no further attempts to
// initiate a connection to that slave until either the BlueCore is reset or the
// slave is removed and re-added to the whitelist.
//
// Documentation from patch_semp2.xap
// ----------------------------------
//
// Issues patched: B-184008
//
// If HCI_SET_EVENT_MASK_PAGE_2 command is sent with wrong parameters
// to Bluecore device, it returns error code
// 'INVALID_HCI_COMMAND_PARAMETERS'. It should return error code
// 'UNKNOWN_HCI_COMMAND'.
//
// Documentation from patch_disc_ll_pdu.xap
// ----------------------------------------
//
// Issues patched: B-179448
//
// If a BlueCore device in the Connection State (regardless if in master or
// slave role) receives an unexpected Data Channel PDU from the peer Link Layer
// during the encryption start or encryption pause procedure, it does not exit
// the Connection State and does not notify the Host with error code
// "Connection Terminated Due to MIC Failure (0x3d)".
//
// Documentation from patch_fsm_shared_patchpoint.c
// ------------------------------------------------
//
// Issues patched: B-216310
//
// In a particular scenario where the peer device retries a Role Switch
// (after a failed Role Switch) without EPR sequence, the Hydra/BlueCore
// Devices do not handle the user data Start/Stop operation properly.
// As a result the user data does not resume after the procedure is finished.
//
// Version information for input files
// -----------------------------------
//
// Created by patchmaker.pl Revision: #68 Date: 2016/01/18
//
// Input file: pb-207.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/pb-207.pb
// File revision: 4
//
// Input file: pb-173-common.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/pb-173-common.pb
// File revision: 7
//
// Input file: report_bt4p2.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/report_bt4p2.pb
// File revision: 1
//
// Input file: patch_ulp_adv_avg_to_calc.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ulp_adv_avg_to_calc.xap
// File revision: 4
//
// Input file: ../patch_utils.inc
// Depot file: //depot/bc/gemini-a12/dev/patches/patch_utils.inc
// File revision: 1
//
// Input file: patch_ble_scan_deaf.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ble_scan_deaf.xap
// File revision: 3
//
// Input file: patch_usb_suspend_deep_sleep.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_usb_suspend_deep_sleep.xap
// File revision: 3
//
// Input file: patch_tx_if_reduction.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_tx_if_reduction.xap
// File revision: 1
//
// Input file: coex_shutdown.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/coex_shutdown.xap
// File revision: 3
//
// Input file: patch_access_address.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_access_address.xap
// File revision: 2
//
// Input file: patch_sched_get_or_peek_message.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_sched_get_or_peek_message.c
// File revision: 3
//
// Input file: patch_sched_get_or_peek_message_part2.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_sched_get_or_peek_message_part2.c
// File revision: 2
//
// Input file: patch_ble_advt_restart.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ble_advt_restart.xap
// File revision: 2
//
// Input file: patch_whitelist_connection_status.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_whitelist_connection_status.xap
// File revision: 4
//
// Input file: patch_semp2.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_semp2.xap
// File revision: 3
//
// Input file: patch_disc_ll_pdu.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_disc_ll_pdu.xap
// File revision: 4
//
// Input file: patch_fsm_shared_patchpoint.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_fsm_shared_patchpoint.c
// File revision: 3
// explicit, PSKEY_HCI_LMP_LOCAL_VERSION (0x010d, 269), 1 words
&010d = 0808
// explicit, PSKEY_LMP_REMOTE_VERSION (0x010e, 270), 1 words
&010e = 0008
// patch_hardware_0, PSKEY_PATCH50 (0x212c, 8492), 56 words
&212c = 0000 f001 0617 0513 0118 ff2b ff0e 1a00 2818 009e 081b f100 8888 24f0 f925 f821 0a17 0184 0cf0 0117 0013 0009 02a4 fb25 fa21 f915 f811 fb55 fa61 09e0 ff84 10f0 0117 0013 0009 02a4 f935 f841 f925 f821 0f1b 0712 10a4 0494 0712 e151 0722 f915 f811 0018 ff2b ff0e f000 0518 00e2 5a79
// patch_hardware_1, PSKEY_PATCH51 (0x212d, 8493), 21 words
&212d = 0002 968a 0863 f925 f821 0757 0663 e099 02ec 05e0 f915 0727 f815 0627 0218 ff2b ff0e 9700 8d18 00e2 7e34
// patch_hardware_2, PSKEY_PATCH52 (0x212e, 8494), 16 words
&212e = 0002 0b5a 0100 7834 0040 0327 0223 f815 e311 0218 ff2b ff0e 0b00 5e18 00e2 59c1
// patch_hardware_3, PSKEY_PATCH53 (0x212f, 8495), 17 words
&212f = 0000 7315 0084 04f0 0800 0014 03e0 f800 1215 0b27 0018 ff2b ff0e 7300 1818 00e2 0549
// patch_hardware_4, PSKEY_PATCH54 (0x2130, 8496), 21 words
&2130 = 0001 53f8 0817 0e27 0c00 6384 07f0 0118 ff2b ff0e 5400 0918 00e2 0917 0118 ff2b ff0e 5400 fb18 00e2 91f6
// patch_hardware_5, PSKEY_PATCH55 (0x2131, 8497), 49 words
&2131 = 0002 c0d5 0423 05f4 031b 0012 0280 1df0 021b 0916 1000 00c4 1ef0 0916 03c4 1bf4 031b 0012 0280 17f4 0380 15f4 0480 13f4 0580 11f4 0680 0ff4 0b80 0df4 0d80 0bf4 019c fb00 6719 0d9e 0218 ff2b ff0e c200 8c18 00e2 0218 ff2b ff0e c100 de18 00e2 c5cf
// patch_hardware_6, PSKEY_PATCH56 (0x2132, 8498), 42 words
&2132 = 0003 243f f40b 0827 0923 e019 0916 01b4 0926 0318 ff2b ff0e 2400 4218 00e2 fa0b 3d14 0327 0114 0227 0014 0127 0027 081b 0816 0218 ff2b ff0e f700 fd18 009e e111 081b 0816 0218 ff2b ff0e 3300 ff18 009e fa0f 40f2
// patch_hardware_7, PSKEY_PATCH57 (0x2133, 8499), 23 words
&2133 = 0003 254e 02c0 0916 1000 00c4 02f4 02b0 0916 fec4 e1b1 0922 0816 0318 ff2b ff0e 2500 5218 8000 00c0 08f2 00e2 e402
// patch_hardware_8, PSKEY_PATCH58 (0x2134, 8500), 16 words
&2134 = 0003 21ca fa0b 0227 0323 e019 0916 01b4 0926 0318 ff2b ff0e 2200 cd18 00e2 22dc
// patch_hardware_9, PSKEY_PATCH59 (0x2135, 8501), 18 words
&2135 = 0000 55e2 09f4 0218 ff2b ff0e 2c00 a718 009e 0314 fc0f 0018 ff2b ff0e 5600 0118 00e2 a008
// patch_hardware_10, PSKEY_PATCH60 (0x2136, 8502), 30 words
&2136 = 0004 0d80 1aa4 0418 ff2b ff0e 1d00 ba18 009e 0184 0d2c 0013 8f00 89d0 0117 bf00 d6d4 0318 ff2b ff0e 2700 4218 009e 0418 ff2b ff0e 0e00 8418 00e2 6855
// patch_hardware_11, PSKEY_PATCH61 (0x2137, 8503), 22 words
&2137 = 0002 4da5 0118 ff2b ff0e 6200 c518 009e 031b 2b22 fcc4 2c26 0114 e700 f025 0218 ff2b ff0e 4e00 a818 00e2 8dfc
// patch_hardware_12, PSKEY_PATCH62 (0x2138, 8504), 19 words
&2138 = 0002 0f22 0310 081b 0100 8022 0100 b012 04f4 0114 e019 0426 0218 ff2b ff0e 0f00 2618 00e2 bc41
// patch_hardware_13, PSKEY_PATCH63 (0x2139, 8505), 12 words
&2139 = 0002 0d95 0513 0100 b022 0218 ff2b ff0e 0f00 db18 00e2 7a40
// patch_fsm_shared_patchpoint, PSKEY_PATCH121 (0x2209, 8713), 36 words
&2209 = fc0b 0b13 0717 1d00 c184 1df0 081b 0016 6384 05f0 1380 17f0 0114 13e0 6084 13f0 0100 da80 0df0 0d1b 5d9a 0af4 b900 f014 0127 0214 0027 e315 0010 000e 019f 0014 0d1b 5d26 fc0f a1a6
// patch_sched_get_or_peek_message, PSKEY_PATCH123 (0x220b, 8715), 49 words
&220b = fa0b 0717 0484 2cf0 0617 0690 e119 0c00 d438 041a 001a 022b 23f4 0116 0184 20f0 0216 0327 1df4 e119 0016 0784 19f0 e500 ab15 8000 0054 0100 c018 ff2b fe27 0317 ff0e fe9f e199 0cf4 7d00 f214 0127 0014 0027 0317 000e 019f 0014 021b 0226 fa0f 8392
// patch_spare1, PSKEY_PATCH155 (0x222b, 8747), 60 words
&222b = e70b 1627 a100 8514 0227 0214 0127 6b00 d814 0427 0214 0327 0417 fe27 0317 ff27 1613 0230 0814 0027 e415 0534 ff0e fe9f 0513 0009 01a4 e015 7fc4 7f84 1bf0 0617 1584 18f0 161b 0116 010e 029f e119 049a 11f4 0116 4184 0ef0 e500 ac11 8000 0050 0100 c014 ff27 fe23 0816 ff0e fe9f 0114 02e0 0014 e70f 4d65
// patch_spare2, PSKEY_PATCH156 (0x222c, 8748), 40 words
&222c = f40b 0927 2900 d414 0427 0314 0327 3500 ea14 0627 0314 0527 2900 9614 0827 0414 0727 0917 0110 070e 089f 0917 030e 049f 0617 fe27 0517 ff27 7f14 0027 1514 0127 2a14 0227 0114 0913 ff0e fe9f f40f 3478
&01fe = 6590
//Interface, BCSP
//&01f9 = 0001
//Interface, H4
&01f9 = 0003
//Bit rate for 8811, 115200
&01ea = 0001 c200

View File

@@ -1,53 +0,0 @@
#
# Copyright (C) 2016 Nordic Semiconductor ASA.
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bluetooth-6lowpand
PKG_VERSION:=0.0.1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/NordicSemiconductor/Linux-ble-6lowpan-joiner.git
PKG_SOURCE_VERSION:=5ce5b248846a6d4ac4a609eb0e8d023cf920b247
PKG_SOURCE_PROTO:=git
BLUEZ_DIR:=$(wildcard $(BUILD_DIR)/bluez-*)
TARGET_CFLAGS += -I$(BLUEZ_DIR)
TARGET_LDFLAGS += -L$(BLUEZ_DIR)/lib/.libs/ -L$(BLUEZ_DIR)/src/.libs/ -lshared-mainloop -lbluetooth-internal
include $(INCLUDE_DIR)/package.mk
define Package/bluetooth-6lowpand
SECTION:=base
CATEGORY:=Network
TITLE:=Bluetooth LE 6lowpan joiner daemon
URL:=http://www.nordicsemi.com/
DEPENDS:=+libusb-1.0 +bluez-libs
endef
define Package/bluetooth-6lowpand/description
Bluetooth Low Energy IPSP device scanner and connection daemon.
The Daemon can be used to whitelist certain IPSP Bluetooth LE MAC
addresses, or autoconnect using SSID and Key derived from Wifi AP
setup to authenticate the devices in order to connect. Also, manual
configuration of software SSID and Key can be used.
endef
define Package/bluetooth-6lowpand/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/bluetooth_6lowpand.init $(1)/etc/init.d/bluetooth_6lowpand
$(INSTALL_DIR) $(1)/etc/bluetooth
$(INSTALL_DATA) ./files/bluetooth_6lowpand.conf $(1)/etc/bluetooth
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bluetooth_6lowpand $(1)/usr/sbin
endef
$(eval $(call BuildPackage,bluetooth-6lowpand))

View File

@@ -1,24 +0,0 @@
#!/bin/sh /etc/rc.common
START=63
PROG=/usr/sbin/bluetooth_6lowpand
HCICONFIG=/usr/bin/hciconfig
start() {
config_load btle
config_get enable bluetooth_6lowpand enable 0
[ "$enable" -eq 1 ] || return
echo "start bluetooth_6lowpand"
sleep 1
echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
sleep 1
killall bluetoothd
sleep 1
$HCICONFIG hci0 reset
$PROG -w 3 -t 5 -a -d
}
stop() {
echo "stop bluetooth_6lowpand"
killall -9 bluetooth_6lowpand
}

View File

@@ -1,33 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bluez-ibeacon
PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/bluez-ibeacon
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2022-10-31
PKG_SOURCE_VERSION:=07c082bf3e139ce061ff62a42b7876860256f4ea
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=MIT
include $(INCLUDE_DIR)/package.mk
define Package/bluez-ibeacon
SECTION:=utils
CATEGORY:=Utilities
TITLE:=bluez-ibeacon
DEPENDS:=+bluez-libs
endef
define Build/Compile
$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/bluez-beacon $(MAKE_FLAGS)
endef
define Package/bluez-ibeacon/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bluez-beacon/ibeacon $(1)/usr/sbin/
$(INSTALL_BIN) ./files/ibeacon $(1)/etc/init.d/ibeacon
endef
$(eval $(call BuildPackage,bluez-ibeacon))

View File

@@ -1,25 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
USE_PROCD=1
PROG=/usr/sbin/ibeacon
service_triggers() {
procd_add_reload_trigger btle
}
start_service() {
config_load btle
config_get enable ibeacon enable 0
config_get uuid ibeacon uuid 0
config_get major ibeacon major 0
config_get minor ibeacon minor 0
[ "$enable" -eq 1 ] || return
procd_open_instance
procd_set_param command "$PROG" 200 "${uuid}" "${major}" "${minor}" -29
procd_set_param respawn
procd_close_instance
}

View File

@@ -1,29 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=nrf52840
PKG_RELEASE:=1
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
include $(INCLUDE_DIR)/package.mk
define Package/nrf52840
SECTION:=utils
CATEGORY:=Utilities
TITLE:=TIP NRF52840 support package
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile/Default
endef
Build/Compile = $(Build/Compile/Default)
define Package/nrf52840/install
$(CP) ./files/* $(1)
endef
$(eval $(call BuildPackage,nrf52840))

View File

@@ -1,21 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
boot() {
. /lib/functions/system.sh
case $(board_name) in
edgecore,eap102|\
edgecore,oap102|\
edgecore,oap103)
echo 54 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio54/direction
echo 0 > /sys/class/gpio/gpio54/value
echo 1 > /sys/class/gpio/gpio54/value
btmgmt --index 0 static-addr FF:02:03:04:05:FF
btmgmt --index 0 auto-power
hciconfig hci0 up
hcitool -i hci0 cmd 0x3f 0x006
;;
esac
}

View File

@@ -1,320 +0,0 @@
// =============================================================================
//
// Copyright (c) 2015 - 2017 Qualcomm Technologies International, Ltd.
// All Rights Reserved.
// Qualcomm Technologies International, Ltd. Confidential and Proprietary.
// report this in case of problems:
// $Revision: #8 $
// Built Mon Feb 20 11:33:32 2017 GMT
// Checked-in $DateTime: 2017/02/20 11:36:26 $
// $File: //depot/bc/gemini-a12/dev/patches/10520/pb-207.psr $
//
// Patch is for build 10520 gem_5hci_rom_bt4.1_gemA12_1407301204_dspm_encr128
//
// Issues patched: B-158094, B-169261, B-171616, B-174351, B-176411,
// B-179448, B-180762, B-184008, B-206751, B-208678,
// B-216310, B-220605, B-223811
//
// Documentation from pb-207.pb
// ----------------------------
//
// General purpose patch and PSKEY bundle for CSR8811
// and CSR8311 A12 BT4.2 (build ID 10520).
//
// Documentation from pb-173-common.pb
// -----------------------------------
//
// General patch bundle for Gemini-A12 (build ID 10520)
// Patches and keys in here should be common to all
// package variants.
//
// Documentation from report_bt4p2.pb
// ----------------------------------
//
// Issues patched: B-174351
//
// Report BT version 4.2
//
// Documentation from patch_ulp_adv_avg_to_calc.xap
// ------------------------------------------------
//
// Issues patched: B-171616
//
// BlueCore can be configured through BCCMDVARID_BLE_CONFIG_ADV_RSSI_AVG_PARAM
// to report the advertising rssi average through LE ADVERTISING REPORT to the
// host for a given PEER LE device.
// For more information, See CS-317256-AN.
//
// If the BlueCore is unable to receive a LE ADVERTISING REPORT from the PEER
// before a configured average rssi supervision timeout, then the BlueCore
// should send a LE ADVERTISING REPORT with rssi value equal to -127 conveying
// that the PEER is out of the range; however, it fails to do this.
//
// Documentation from patch_ble_scan_deaf.xap
// ------------------------------------------
//
// Issues patched: B-158094
//
// When BlueCore is asked to do BLE scanning, it scans for a window
// approximately 2.5% shorter than asked for. Generally, this does
// not cause noticeable effects; sometimes BLE adverts can be missed
// making connection initialisation between two BLE devices take
// somewhat longer than expected. In pathological cases, especially
// if the scan window is long, connections may fail to be made entirely.
//
// Documentation from patch_usb_suspend_deep_sleep.xap
// ---------------------------------------------------
//
// Issues patched: B-176411
//
// When BlueCore device is bus powered and is in USB suspend mode,
// the current consumption is approximately 8 mA which is higher
// than the expected current of 250 uA
//
// Documentation from patch_tx_if_reduction.xap
// --------------------------------------------
//
// Issues patched: B-169261
//
// When a BlueCore7 device is configured to use a +/-500 kHz transmit IF, this
// can be overridden and a +/-375 kHz IF used instead. This reduces the
// bandwidthof the transmit spectrum providing a greater margin in a Chinese
// regulatory test.
// Only transmit IFs of +/-500 kHz may be reduced; if BlueCore7 is configured to
// use a TX IF of +/-1 MHz IF that will remain unchanged.
//
// Documentation from coex_shutdown.xap
// ------------------------------------
//
// Issues patched: B-208678
//
// With Coexistence Unity-3 scheme, If the WLAN_DENY signal is asserted during
// the initial phase of an adaptive frequency hopping(AFH) scan, the Bluecore
// device fails to deassert its BT_ACTIVE signal
//
// Documentation from patch_access_address.xap
// -------------------------------------------
//
// Issues patched: B-206751
//
// BlueCore devices may generate access addresses that only
// have one bit transition in the 6 most significant bits.
// The problem is seen on access addresses that have the most
// significant bit set to one and only have one bit transition
// in the 6 most significant bits.
//
// Furthermore, the access address, whilst not identical to the
// advertising channel packets Access Address, may differ by
// only one bit.
//
// Documentation from patch_sched_get_or_peek_message.c
// ----------------------------------------------------
//
// Issues patched: B-220605
//
// During the crossover of a locally initiated
// LMP_unsniff_req and peer initiated LMP_sniff_subrate_req,
// Bluecore responds with LMP_Sniff_Subrate_Rsp even if it
// has initiated LMP_unsniff. This probably confuses peer and
// peer stops responding, leading to a timeout.
//
// Documentation from patch_sched_get_or_peek_message_part2.c
// ----------------------------------------------------------
//
// Issues patched: B-220605
//
// During the crossover of a locally initiated
// LMP_unsniff_req and peer initiated LMP_sniff_subrate_req,
// Bluecore responds with LMP_Sniff_Subrate_Rsp even if it
// has initiated LMP_unsniff. This probably confuses peer and
// peer stops responding, leading to a timeout.
//
// Documentation from patch_ble_advt_restart.xap
// ---------------------------------------------
//
// Issues patched: B-223811
//
// When advertisements are disabled before the expiry of the interval
// and enabled immediately the advertisements are not sent before the
// expiry of the advertising interval
//
// Documentation from patch_whitelist_connection_status.xap
// --------------------------------------------------------
//
// Issues patched: B-180762
//
// If a BlueCore device attempts but fails to form a Low Energy (LE) connection
// to a remote slave using the whitelist, it will make no further attempts to
// initiate a connection to that slave until either the BlueCore is reset or the
// slave is removed and re-added to the whitelist.
//
// Documentation from patch_semp2.xap
// ----------------------------------
//
// Issues patched: B-184008
//
// If HCI_SET_EVENT_MASK_PAGE_2 command is sent with wrong parameters
// to Bluecore device, it returns error code
// 'INVALID_HCI_COMMAND_PARAMETERS'. It should return error code
// 'UNKNOWN_HCI_COMMAND'.
//
// Documentation from patch_disc_ll_pdu.xap
// ----------------------------------------
//
// Issues patched: B-179448
//
// If a BlueCore device in the Connection State (regardless if in master or
// slave role) receives an unexpected Data Channel PDU from the peer Link Layer
// during the encryption start or encryption pause procedure, it does not exit
// the Connection State and does not notify the Host with error code
// "Connection Terminated Due to MIC Failure (0x3d)".
//
// Documentation from patch_fsm_shared_patchpoint.c
// ------------------------------------------------
//
// Issues patched: B-216310
//
// In a particular scenario where the peer device retries a Role Switch
// (after a failed Role Switch) without EPR sequence, the Hydra/BlueCore
// Devices do not handle the user data Start/Stop operation properly.
// As a result the user data does not resume after the procedure is finished.
//
// Version information for input files
// -----------------------------------
//
// Created by patchmaker.pl Revision: #68 Date: 2016/01/18
//
// Input file: pb-207.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/pb-207.pb
// File revision: 4
//
// Input file: pb-173-common.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/pb-173-common.pb
// File revision: 7
//
// Input file: report_bt4p2.pb
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/report_bt4p2.pb
// File revision: 1
//
// Input file: patch_ulp_adv_avg_to_calc.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ulp_adv_avg_to_calc.xap
// File revision: 4
//
// Input file: ../patch_utils.inc
// Depot file: //depot/bc/gemini-a12/dev/patches/patch_utils.inc
// File revision: 1
//
// Input file: patch_ble_scan_deaf.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ble_scan_deaf.xap
// File revision: 3
//
// Input file: patch_usb_suspend_deep_sleep.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_usb_suspend_deep_sleep.xap
// File revision: 3
//
// Input file: patch_tx_if_reduction.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_tx_if_reduction.xap
// File revision: 1
//
// Input file: coex_shutdown.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/coex_shutdown.xap
// File revision: 3
//
// Input file: patch_access_address.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_access_address.xap
// File revision: 2
//
// Input file: patch_sched_get_or_peek_message.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_sched_get_or_peek_message.c
// File revision: 3
//
// Input file: patch_sched_get_or_peek_message_part2.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_sched_get_or_peek_message_part2.c
// File revision: 2
//
// Input file: patch_ble_advt_restart.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_ble_advt_restart.xap
// File revision: 2
//
// Input file: patch_whitelist_connection_status.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_whitelist_connection_status.xap
// File revision: 4
//
// Input file: patch_semp2.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_semp2.xap
// File revision: 3
//
// Input file: patch_disc_ll_pdu.xap
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_disc_ll_pdu.xap
// File revision: 4
//
// Input file: patch_fsm_shared_patchpoint.c
// Depot file: //depot/bc/gemini-a12/dev/patches/10520/patch_fsm_shared_patchpoint.c
// File revision: 3
// explicit, PSKEY_HCI_LMP_LOCAL_VERSION (0x010d, 269), 1 words
&010d = 0808
// explicit, PSKEY_LMP_REMOTE_VERSION (0x010e, 270), 1 words
&010e = 0008
// patch_hardware_0, PSKEY_PATCH50 (0x212c, 8492), 56 words
&212c = 0000 f001 0617 0513 0118 ff2b ff0e 1a00 2818 009e 081b f100 8888 24f0 f925 f821 0a17 0184 0cf0 0117 0013 0009 02a4 fb25 fa21 f915 f811 fb55 fa61 09e0 ff84 10f0 0117 0013 0009 02a4 f935 f841 f925 f821 0f1b 0712 10a4 0494 0712 e151 0722 f915 f811 0018 ff2b ff0e f000 0518 00e2 5a79
// patch_hardware_1, PSKEY_PATCH51 (0x212d, 8493), 21 words
&212d = 0002 968a 0863 f925 f821 0757 0663 e099 02ec 05e0 f915 0727 f815 0627 0218 ff2b ff0e 9700 8d18 00e2 7e34
// patch_hardware_2, PSKEY_PATCH52 (0x212e, 8494), 16 words
&212e = 0002 0b5a 0100 7834 0040 0327 0223 f815 e311 0218 ff2b ff0e 0b00 5e18 00e2 59c1
// patch_hardware_3, PSKEY_PATCH53 (0x212f, 8495), 17 words
&212f = 0000 7315 0084 04f0 0800 0014 03e0 f800 1215 0b27 0018 ff2b ff0e 7300 1818 00e2 0549
// patch_hardware_4, PSKEY_PATCH54 (0x2130, 8496), 21 words
&2130 = 0001 53f8 0817 0e27 0c00 6384 07f0 0118 ff2b ff0e 5400 0918 00e2 0917 0118 ff2b ff0e 5400 fb18 00e2 91f6
// patch_hardware_5, PSKEY_PATCH55 (0x2131, 8497), 49 words
&2131 = 0002 c0d5 0423 05f4 031b 0012 0280 1df0 021b 0916 1000 00c4 1ef0 0916 03c4 1bf4 031b 0012 0280 17f4 0380 15f4 0480 13f4 0580 11f4 0680 0ff4 0b80 0df4 0d80 0bf4 019c fb00 6719 0d9e 0218 ff2b ff0e c200 8c18 00e2 0218 ff2b ff0e c100 de18 00e2 c5cf
// patch_hardware_6, PSKEY_PATCH56 (0x2132, 8498), 42 words
&2132 = 0003 243f f40b 0827 0923 e019 0916 01b4 0926 0318 ff2b ff0e 2400 4218 00e2 fa0b 3d14 0327 0114 0227 0014 0127 0027 081b 0816 0218 ff2b ff0e f700 fd18 009e e111 081b 0816 0218 ff2b ff0e 3300 ff18 009e fa0f 40f2
// patch_hardware_7, PSKEY_PATCH57 (0x2133, 8499), 23 words
&2133 = 0003 254e 02c0 0916 1000 00c4 02f4 02b0 0916 fec4 e1b1 0922 0816 0318 ff2b ff0e 2500 5218 8000 00c0 08f2 00e2 e402
// patch_hardware_8, PSKEY_PATCH58 (0x2134, 8500), 16 words
&2134 = 0003 21ca fa0b 0227 0323 e019 0916 01b4 0926 0318 ff2b ff0e 2200 cd18 00e2 22dc
// patch_hardware_9, PSKEY_PATCH59 (0x2135, 8501), 18 words
&2135 = 0000 55e2 09f4 0218 ff2b ff0e 2c00 a718 009e 0314 fc0f 0018 ff2b ff0e 5600 0118 00e2 a008
// patch_hardware_10, PSKEY_PATCH60 (0x2136, 8502), 30 words
&2136 = 0004 0d80 1aa4 0418 ff2b ff0e 1d00 ba18 009e 0184 0d2c 0013 8f00 89d0 0117 bf00 d6d4 0318 ff2b ff0e 2700 4218 009e 0418 ff2b ff0e 0e00 8418 00e2 6855
// patch_hardware_11, PSKEY_PATCH61 (0x2137, 8503), 22 words
&2137 = 0002 4da5 0118 ff2b ff0e 6200 c518 009e 031b 2b22 fcc4 2c26 0114 e700 f025 0218 ff2b ff0e 4e00 a818 00e2 8dfc
// patch_hardware_12, PSKEY_PATCH62 (0x2138, 8504), 19 words
&2138 = 0002 0f22 0310 081b 0100 8022 0100 b012 04f4 0114 e019 0426 0218 ff2b ff0e 0f00 2618 00e2 bc41
// patch_hardware_13, PSKEY_PATCH63 (0x2139, 8505), 12 words
&2139 = 0002 0d95 0513 0100 b022 0218 ff2b ff0e 0f00 db18 00e2 7a40
// patch_fsm_shared_patchpoint, PSKEY_PATCH121 (0x2209, 8713), 36 words
&2209 = fc0b 0b13 0717 1d00 c184 1df0 081b 0016 6384 05f0 1380 17f0 0114 13e0 6084 13f0 0100 da80 0df0 0d1b 5d9a 0af4 b900 f014 0127 0214 0027 e315 0010 000e 019f 0014 0d1b 5d26 fc0f a1a6
// patch_sched_get_or_peek_message, PSKEY_PATCH123 (0x220b, 8715), 49 words
&220b = fa0b 0717 0484 2cf0 0617 0690 e119 0c00 d438 041a 001a 022b 23f4 0116 0184 20f0 0216 0327 1df4 e119 0016 0784 19f0 e500 ab15 8000 0054 0100 c018 ff2b fe27 0317 ff0e fe9f e199 0cf4 7d00 f214 0127 0014 0027 0317 000e 019f 0014 021b 0226 fa0f 8392
// patch_spare1, PSKEY_PATCH155 (0x222b, 8747), 60 words
&222b = e70b 1627 a100 8514 0227 0214 0127 6b00 d814 0427 0214 0327 0417 fe27 0317 ff27 1613 0230 0814 0027 e415 0534 ff0e fe9f 0513 0009 01a4 e015 7fc4 7f84 1bf0 0617 1584 18f0 161b 0116 010e 029f e119 049a 11f4 0116 4184 0ef0 e500 ac11 8000 0050 0100 c014 ff27 fe23 0816 ff0e fe9f 0114 02e0 0014 e70f 4d65
// patch_spare2, PSKEY_PATCH156 (0x222c, 8748), 40 words
&222c = f40b 0927 2900 d414 0427 0314 0327 3500 ea14 0627 0314 0527 2900 9614 0827 0414 0727 0917 0110 070e 089f 0917 030e 049f 0617 fe27 0517 ff27 7f14 0027 1514 0127 2a14 0227 0114 0913 ff0e fe9f f40f 3478
&01fe = 6590
//Interface, BCSP
//&01f9 = 0001
//Interface, H4
&01f9 = 0003
//Bit rate for 8811, 115200
&01ea = 0001 c200

View File

@@ -1,32 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ubtled
PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/ubtled.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2022-10-31
PKG_SOURCE_VERSION:=7e01ab86c562fc8ab3777d04e60b8dce596a4c5f
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/ubtled
SECTION:=utils
CATEGORY:=Utilities
TITLE:=OpenWrt BTLE daemon
DEPENDS:=+libubox +libubus +bluez-libs
endef
define Package/ubtled/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/{config,init.d,uci-defaults}
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ubtled $(1)/usr/sbin/
$(INSTALL_BIN) ./files/ubtled.init $(1)/etc/init.d/ubtled
$(INSTALL_DATA) ./files/btle.config $(1)/etc/config/btle
$(INSTALL_DATA) ./files/99-btle $(1)/etc/uci-defaults/
endef
$(eval $(call BuildPackage,ubtled))

View File

@@ -1,8 +0,0 @@
#!/bin/sh
cat >> /etc/bluetooth/main.conf <<EOF
[General]
Name = TIP AP
[GATT]
[Policy]
EOF

View File

@@ -1,11 +0,0 @@
config ubtled ubtled
option enable 0
config bluetooth_6lowpand bluetooth_6lowpand
option enable 0
config ubtled ibeacon
option enable 0
option uuid 0
option major 0
option minor 0

View File

@@ -1,24 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
USE_PROCD=1
PROG=/usr/sbin/ubtled
service_triggers() {
procd_add_reload_trigger btle
}
start_service() {
config_load btle
config_get enable ubtled enable 0
[ "$enable" -eq 1 ] || return
hciconfig hci0 up
procd_open_instance
procd_set_param command "$PROG"
procd_set_param respawn
procd_close_instance
}

View File

@@ -1,29 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=eltt2
PKG_VERSION:=1.0
PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/eltt2
SECTION:=base
CATEGORY:=Utilities
TITLE:=eltt2
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/eltt2/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/eltt2 $(1)/bin/
endef
define Package/eltt2/extra_provides
echo "libc.so.6";
endef
$(eval $(call BuildPackage,eltt2))

View File

@@ -1,27 +0,0 @@
Copyright (c) 2014, Infineon Technologies AG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,15 +0,0 @@
# Makefile for Embedded Linux TPM Toolbox 2 (ELTT2)
# Copyright (c) Infineon Technologies AG
#CROSS-COMPILE:=../../../../../qsdk/staging_dir/toolchain-arm/bin/arm-openwrt-linux-
#CC:=$(CROSS-COMPILE)gcc
CC = gcc
CFLAGS=-Wall -Wextra -std=c99 -g
all: eltt2
eltt2: eltt2.c eltt2.h
$(CC) $(CFLAGS) eltt2.c -o eltt2
clean:
rm -rf eltt2

View File

@@ -1,230 +0,0 @@
# ELTT2 - Infineon Embedded Linux TPM Toolbox 2 for TPM 2.0
All information in this document is Copyright (c) 2014-2022, Infineon Technologies AG <br>
All rights reserved.
# 1. Welcome
Welcome to Embedded Linux TPM Toolbox 2 (ELTT2). ELTT2 is a single-file executable program intended for testing, performing diagnosis and basic state changes of the Infineon Technologies TPM 2.0.
## 1.1 Prerequisites
To build and run ELTT2 you need GCC and a Linux system capable of hosting a TPM.
ELTT2 may run on many other little-endian hardware and software configurations capable of running Linux and hosting a TPM, but this has not been tested.
ELTT2 does not support machines with a big-endian CPU.
## 1.2 Getting Started
A TPM 2.0 evaluation board can be ordered in the [Hitex Webshop](https://www.ehitex.de/evaluation-boards/infineon/2564/iridium-9670-tpm2.0-spi).
<p align="center">
<img src="https://cloud.githubusercontent.com/assets/19730245/25651091/77a84744-2fe1-11e7-91bd-a2e39678202d.JPG" width="350"/>
</p>
In order to execute ELTT2, you need to compile it first:
1. Switch to the directory with the ELTT2 source code
2. Compile the source code by typing the following command:
make
Due to hardware (and thus TPM) access restrictions for normal users, ELTT2 requires root (aka superuser or administrator) privileges. They can be obtained e.g. by using the 'sudo' command on Debian Linux derivates.
The Infineon [TPM 2.0 Application Note](https://www.infineon.com/dgdl/Infineon-App-Note-SLx9670-TPM2.0_Embedded_RPi_DI_SLx-AN-v01_20-EN.pdf?fileId=5546d46267c74c9a01684b96e69f5d7b) shows how the TPM device driver can be set up (e.g. for Linux Kernel 4.14).
# 2. Usage of ELTT2
## 2.1 Generic Usage
ELTT2 is operated as follows:
Call: `./eltt2 <option(s)>`
For example: `./eltt2 -g` or `./eltt2 -gc`
For getting an overview of the possible commands, run `./eltt2 -h`
Some options require the TPM to be in a specific state. This state is shown in brackets ("[]") behind each command line option in the list below:
\[-\]: none <br>
\[\*\]: the TPM platform hierarchy authorization value is not set (i.e., empty buffer) <br>
\[l\]: the required PCR bank is allocated <br>
\[u\]: started <br>
To get the TPM into the required state, call ELTT2 with the corresponding commands ("x" for a state means that whether this state is required or not depends on the actual command or the command parameters sent eventually to the TPM).
Command line option | Explanation | Precondition
--- | --- | ---
`-a [hash algorithm] <data bytes>` | Hash Sequence SHA-1/256/384 \[default: SHA-1\] | \[u\]
`-A <data bytes>` | Hash Sequence SHA-256 | \[u\]
`-b <command bytes>` | Enter your own TPM command | \[u\]
`-c` | Read Clock | \[u\]
`-d <shutdown type>` | Shutdown | \[u\]
`-e [hash algorithm] <PCR index> <PCR digest>` | PCR Extend SHA-1/256/384 \[default: SHA-1\] | \[u\], \[l\]
`-E <PCR index> <PCR digest>` | PCR Extend SHA-256 | \[u\], \[l\]
`-g` | Get fixed capability values | \[u\]
`-v` | Get variable capability values | \[u\]
`-G <data length>` | Get Random | \[u\]
`-h` | Help | \[-\]
`-l <hash algorithm>` | PCR Allocate SHA-1/256/384 | \[u\], \[\*\]
`-r [hash algorithm] <PCR index>` | PCR Read SHA-1/256/384 \[default: SHA-1\] | \[u\], \[l\]
`-R <PCR index>` | PCR Read SHA-256 | \[u\], \[l\]
`-s [hash algorithm] <data bytes>` | Hash SHA-1/256/384 \[default: SHA-1\] | \[u\]
`-S <data bytes>` | Hash SHA-256 | \[u\]
`-t <test type>` | Self Test | \[u\]
`-T` | Get Test Result | \[u\]
`-u <startup type>` | Startup | \[-\]
`-z <PCR index>` | PCR Reset | \[u\]
Additional information:
`-a`: <br>
With the "-a" command you can hash given data with the SHA-1/256/384 hash algorithm. This hash sequence sends 3 commands \[start, update, complete\] to the TPM and allows to hash an arbitrary amount of data. For example, use the following command to hash the byte sequence {0x41, 0x62, 0x43, 0x64}: <br>
`./eltt2 -a 41624364` Hash given data with SHA-1 hash algorithm. <br>
or <br>
`./eltt2 -a sha1 41624364` Hash given data with SHA-1 hash algorithm. <br>
`./eltt2 -a sha256 41624364` Hash given data with SHA-256 hash algorithm. <br>
`./eltt2 -a sha384 41624364` Hash given data with SHA-384 hash algorithm. <br>
`-A`: <br>
With the "-A" command you can hash given data with the SHA-256 hash algorithm. This hash sequence sends 3 commands \[start, update, complete\] to the TPM and allows to hash an arbitrary amount of data. For example, use the following command to hash the byte sequence {0x41, 0x62, 0x43, 0x64}: <br>
`./eltt2 -A 41624364`
`-b`: <br>
With the "-b" command you can enter your own TPM command bytes and read the TPM response. For example, use the following command to send a TPM2_Startup with startup type CLEAR to the TPM: <br>
`./eltt2 -b 80010000000C000001440000`
`-c`: <br>
With the "-c" command you can read the clock values of the TPM.
`-d`: <br>
With the "-d" command you can issue a TPM shutdown. It has 2 options: <br>
`./eltt2 -d` <br>
or <br>
`./eltt2 -d clear` send a TPM2_Shutdown command with shutdown type CLEAR to the TPM. <br>
`./eltt2 -d state` send a TPM2_Shutdown command with shutdown type STATE to the TPM. <br>
`-e`: <br>
With the "-e" command you can extend bytes in the selected PCR with SHA-1/256/384. To do so, you have to enter the index of PCR in hexadecimal that you like to extend and the digest you want to extend the selected PCR with. Note that you can only extend PCRs with index 0 to 16 and PCR 23 and that the digest must have a length of 20/32/48 bytes (will be padded with 0 if necessary). The TPM then builds an SHA-1/256/384 hash over the PCR data in the selected PCR and the digest you provided and writes the result back to the selected PCR. For example, use the following command to extend PCR 23 (0x17) with the byte sequence {0x41, 0x62, 0x43, 0x64, 0x00, ... (will be filled with 0x00)}: <br>
`./eltt2 -e 17 41624364` Extend bytes in PCR 23 with SHA-1. <br>
or <br>
`./eltt2 -e sha1 17 41624364` Extend bytes in PCR 23 with SHA-1. <br>
`./eltt2 -e sha256 17 41624364` Extend bytes in PCR 23 with SHA-256. <br>
`./eltt2 -e sha384 17 41624364` Extend bytes in PCR 23 with SHA-384. <br>
`-E`: <br>
With the "-E" command you can extend bytes in the selected PCR with SHA-256. To do so, you have to enter the index of PCR in hexadecimal that you like to extend and the digest you want to extend the selected PCR with. Note that you can only extend PCRs with index 0 to 16 and PCR 23 and that the digest must have a length of 32 bytes (will be padded with 0 if necessary). The TPM then builds an SHA-256 hash over the PCR data in the selected PCR and the digest you provided and writes the result back to the selected PCR. For example, use the following command to extend PCR 23 (0x17) with the byte sequence {0x41, 0x62, 0x43, 0x64, 0x00, ... (will be filled with 0x00)}: <br>
`./eltt2 -E 17 41624364`
`-g`: <br>
With the "-g" command you can read the TPM's fixed properties.
`-v`: <br>
With the "-v" command you can read the TPM's variable properties.
`-G`: <br>
With the "-G" command you can get a given amount of random bytes. Note that you can only request a maximum amount of 32 random bytes at once. For example, use the following command to get 20 (0x14) random bytes: <br>
`./eltt2 -G 14`
`-l`: <br>
With the "-l" command you can allocate the SHA-1/256/384 PCR bank. Take note of two things. Firstly, the command requires a platform authorization value and it is set to an empty buffer; hence the command cannot be used if the TPM platform authorization value is set (e.g., by UEFI). Secondly, when the command is executed successfully a TPM reset has to follow for it to take effect. For example, use the following command to allocate a PCR bank: <br>
`./eltt2 -l sha1` Allocate SHA-1 PCR bank. <br>
`./eltt2 -l sha256` Allocate SHA-256 PCR bank. <br>
`./eltt2 -l sha384` Allocate SHA-384 PCR bank. <br>
`-r`: <br>
With the "-r" command you can read data from a selected SHA-1/256/384 PCR. For example, use the following command to read data from PCR 23 (0x17): <br>
`./eltt2 -r 17` Read data from SHA-1 PCR 23. <br>
or <br>
`./eltt2 -r sha1 17` Read data from SHA-1 PCR 23. <br>
`./eltt2 -r sha256 17` Read data from SHA-256 PCR 23. <br>
`./eltt2 -r sha384 17` Read data from SHA-384 PCR 23. <br>
`-R`: <br>
With the "-R" command you can read data from a selected SHA-256 PCR. For example, use the following command to read data from PCR 23 (0x17): <br>
`./eltt2 -R 17`
`-s`: <br>
With the "-s" command you can hash given data with the SHA-1/256/384 hash algorithm. This command only allows a limited amount of data to be hashed (depending on the TPM's maximum input buffer size). For example, use the following command to hash the byte sequence {0x41, 0x62, 0x43, 0x64}: <br>
`./eltt2 -s 41624364` Hash given data with SHA-1 hash algorithm. <br>
or <br>
`./eltt2 -s sha1 41624364` Hash given data with SHA-1 hash algorithm. <br>
`./eltt2 -s sha256 41624364` Hash given data with SHA-256 hash algorithm. <br>
`./eltt2 -s sha384 41624364` Hash given data with SHA-384 hash algorithm. <br>
`-S`: <br>
With the "-S" command you can hash given data with the SHA-256 hash algorithm. This command only allows a limited amount of data to be hashed (depending on the TPM input buffer size). For example, use the following command to hash the byte sequence {0x41, 0x62, 0x43, 0x64}: <br>
`./eltt2 -S 41624364`
`-t`: <br>
With the "-t" command you can issue a TPM selftest. It has 3 options: <br>
`./eltt2 -t` <br>
or<br>
`./eltt2 -t not_full` Perform a partial TPM2_Selftest to test previously untested TPM capabilities. <br>
`./eltt2 -t full` Perform a full TPM2_Selftest to test all TPM capabilities. <br>
`./eltt2 -t incremental` Perform a test of selected algorithms.
`-T`: <br>
With the "-T" command you can read the results of a previously run selftest.
`-u`: <br>
With the "-u" command you can issue a TPM startup command. It has 2 options: <br>
`./eltt2 -u` <br>
or <br>
`./eltt2 -u clear` send a TPM2_Startup with startup type CLEAR to the TPM. <br>
`./eltt2 -u state` send a TPM2_Startup with startup type STATE to the TPM.
`-z`: <br>
With the "-z" command you can reset a selected PCR. Note that you can only reset PCRs 16 and 23. For example, use the following command to reset PCR 23 (0x17): <br>
`./eltt2 -z 17`
## 2.2 Examples:
In order to work with the TPM, perform the following steps:
- Send the TPM2_Startup command: `./eltt2 -u`
# 3. If you have questions
If you have any questions or problems, please read the section "FAQ and
Troubleshooting" in this document.
In case you still have questions, contact your local Infineon
Representative.
Further information is available at <https://www.infineon.com/tpm>.
# 4. FAQ and Troubleshooting
If you encounter any error, please make sure that
- the TPM is properly connected.
- the TPM driver is loaded, i.e. check that "/dev/tpm0" exists. In case of driver loading problems (e.g. shown by "Error opening device"), reboot your system and try to load the driver again.
- ELTT2 has been started with root permissions. Please note that ELTT2 needs root permissions for all commands.
- the TPM is started. (See section 2.2 in this document on how to do this.)
The following list shows the most common errors and their solution:
The ELTT2 response is "Error opening the device.":
- You need to load a TPM driver before you can work with ELTT2.
- You need to start ELTT2 with root permissions.
The ELTT2 responds with error code 0x100.
- You need to send the TPM2_Startup command, or you did send it twice. In
case you have not sent it yet, do so with `./eltt2 -u`.
The TPM does not change any of the permanent flags shown by sending the "-g"
command , e.g. after a force clear.
- The TPM requires a reset in order to change any of the permanent flags.
Press the reset button or disconnect the TPM to do so.
The value of a PCR does not change after sending PCR extend or reset.
- With the application permissions you cannot modify every PCR. For more
details, please refer to the description for the different PCR commands
in this file.

View File

@@ -1,362 +0,0 @@
--------------------------------------------------------------------------------
Infineon Embedded Linux TPM Toolbox 2 (ELTT2) for TPM 2.0 v1.1
Infineon Technologies AG
All information in this document is Copyright (c) 2014, Infineon Technologies AG
All rights reserved.
--------------------------------------------------------------------------------
Contents:
1. Welcome
1.1 Prerequisites
1.2 Contents of the package
1.3 Getting Started
2. Usage of Embedded Linux TPM Toolbox 2 (ELTT2)
2.1 Generic Usage
2.2 Examples
3. If you have questions
4. Release Info
5. FAQ
================================================================================
1. Welcome
Welcome to Embedded Linux TPM Toolbox 2 (ELTT2).
ELTT2 is a single-file executable program intended for testing, performing
diagnosis and basic state changes of the Infineon Technologies TPM 2.0.
1.1 Prerequisites
To build and run ELTT2 you need GCC and a Linux system capable of hosting a
TPM 2.0.
Tested PC Platforms (x86):
- Ubuntu (R) Linux 12.04 LTS - 64 bit (modified Kernel 3.15.4)
with Infineon TPM 2.0 SLB9665 Firmware 5.22
Tested Embedded Platforms (ARM):
- Android 6.0 "Marshmallow" - 64 bit (modified Kernel 3.18.0+) on HiKey
with Prototype Infineon I2C TPM 2.0 for Embedded Platforms
ELTT2 may run on many other little-endian hardware and software
configurations capable of running Linux and hosting a TPM 2.0, but this has
not been tested.
ELTT2 does not support machines with a big-endian CPU.
1.2 Contents of Package
ELTT2 consists of the following files:
- eltt2.c
Contains all method implementations of ELTT2.
- eltt2.h
Contains all constant definitions, method and command byte declarations
for the operation of ELTT2.
- License.txt
Contains the license agreement for ELTT2.
- Makefile
Contains the command to compile ELTT2.
- README.txt
This file.
1.3 Getting Started
In order to execute ELTT2, you need to compile it first:
1. Switch to the directory with the ELTT2 source code
2. Compile the source code by typing the following command:
make
Due to hardware (and thus TPM) access restrictions for normal users, ELTT2
requires root (aka superuser or administrator) privileges. They can be
obtained e.g. by using the 'sudo' command on Debian Linux derivates.
2. Usage of ELTT2
2.1 Generic Usage
ELTT2 is operated as follows:
Call: ./eltt2 <option(s)>
For example: ./eltt2 -g or ./eltt2 -gc
For getting an overview of the possible commands, run ./eltt2 -h
Some options require the TPM to be in a specific state. This state is shown
in brackets ("[]") behind each command line option in the list below:
[-]: none
[*]: the TPM platform hierarchy authorization value is not set (i.e., empty buffer)
[l]: the required PCR bank is allocated
[u]: started
To get the TPM into the required state, call ELTT2 with the corresponding
commands ("x" for a state means that whether this state is required or not
depends on the actual command or the command parameters sent eventually to
the TPM).
Command line options: Preconditions:
-a [hash algorithm] <data bytes>: Hash Sequence SHA-1/256/384 [default: SHA-1] [u]
-A <data bytes>: Hash Sequence SHA-256 [u]
-b <command bytes>: Enter your own TPM command [u]
-c: Read Clock [u]
-d <shutdown type>: Shutdown [u]
-e [hash algorithm] <PCR index> <PCR digest>: PCR Extend SHA-1/256/384 [default: SHA-1] [u], [l]
-E <PCR index> <PCR digest>: PCR Extend SHA-256 [u], [l]
-g: Get fixed capability values [u]
-v: Get variable capability values [u]
-G <data length>: Get Random [u]
-h: Help [-]
-l <hash algorithm>: PCR Allocate SHA-1/256/384 [u], [*]
-r [hash algorithm] <PCR index>: PCR Read SHA-1/256/384 [default: SHA-1] [u], [l]
-R <PCR index>: PCR Read SHA-256 [u], [l]
-s [hash algorithm] <data bytes>: Hash SHA-1/SHA256 [default: SHA-1] [u]
-S <data bytes>: Hash SHA-256 [u]
-t <test type>: Self Test [u]
-T: Get Test Result [u]
-u <startup type>: Startup [-]
-z <PCR index>: PCR Reset [u]
Additional information:
-a:
With the "-a" command you can hash given data with the SHA-1/256/384 hash
algorithm. This hash sequence sends 3 commands [start, update, complete]
to the TPM and allows to hash an arbitrary amount of data.
For example, use the following command to hash the byte sequence {0x41,
0x62, 0x43, 0x64}:
./eltt2 -a 41624364 Hash given data with SHA-1 hash algorithm.
or
./eltt2 -a sha1 41624364 Hash given data with SHA-1 hash algorithm.
./eltt2 -a sha256 41624364 Hash given data with SHA-256 hash algorithm.
-A:
With the "-A" command you can hash given data with the SHA-256 hash
algorithm. This hash sequence sends 3 commands [start, update, complete] to
the TPM and allows to hash an arbitrary amount of data.
For example, use the following command to hash the byte sequence {0x41,
0x62, 0x43, 0x64}:
./eltt2 -A 41624364
-b:
With the "-b" command you can enter your own TPM command bytes and read the
TPM response.
For example, use the following command to send a TPM2_Startup with startup
type CLEAR to the TPM:
./eltt2 -b 80010000000C000001440000
-c:
With the "-c" command you can read the clock values of the TPM.
-d:
With the "-d" command you can issue a TPM shutdown. It has 2 options:
./eltt2 -d
or
./eltt2 -d clear send a TPM2_Shutdown command with shutdown type CLEAR to
the TPM.
./eltt2 -d state send a TPM2_Shutdown command with shutdown type STATE to
the TPM.
-e:
With the "-e" command you can extend bytes in the selected PCR with SHA-1/256/384.
To do so, you have to enter the index of PCR in hexadecimal that you like to
extend and the digest you want to extend the selected PCR with. Note that
you can only extend PCRs with index 0 to 16 and PCR 23 and that the digest
must have a length of 20/32/48 bytes (will be padded with 0 if necessary).
The TPM then builds an SHA-1/256/384 hash over the PCR data in the selected PCR
and the digest you provided and writes the result back to the selected PCR.
For example, use the following command to extend PCR 23 (0x17) with the byte
sequence {0x41, 0x62, 0x43, 0x64, 0x00, ... (will be filled with 0x00)}:
./eltt2 -e 17 41624364 Extend bytes in PCR 23 with SHA-1.
or
./eltt2 -e sha1 17 41624364 Extend bytes in PCR 23 with SHA-1.
./eltt2 -e sha256 17 41624364 Extend bytes in PCR 23 with SHA-256.
-E:
With the "-E" command you can extend bytes in the selected PCR with SHA-256.
To do so, you have to enter the index of PCR in hexadecimal that you like to
extend and the digest you want to extend the selected PCR with. Note that
you can only extend PCRs with index 0 to 16 and PCR 23 and that the digest
must have a length of 32 bytes (will be padded with 0 if necessary).
The TPM then builds an SHA-256 hash over the PCR data in the selected PCR
and the digest you provided and writes the result back to the selected PCR.
For example, use the following command to extend PCR 23 (0x17) with the byte
sequence {0x41, 0x62, 0x43, 0x64, 0x00, ... (will be filled with 0x00)}:
./eltt2 -E 17 41624364
-g:
With the "-g" command you can read the TPM's fixed properties.
-v:
With the "-v" command you can read the TPM's variable properties.
-G:
With the "-G" command you can get a given amount of random bytes. Note that
you can only request a maximum amount of 32 random bytes at once.
For example, use the following command to get 20 (0x14) random bytes:
./eltt2 -G 14
-l:
With the "-l" command you can allocate the SHA-1/256/384 PCR bank.
Take note of two things. Firstly, the command requires a platform
authorization value and it is set to an empty buffer; hence the command
cannot be used if the TPM platform authorization value is set (e.g., by UEFI).
Secondly, when the command is executed successfully a TPM reset has to
follow for it to take effect. For example, use the following command to
allocate a PCR bank:
./eltt2 -l sha1 Allocate SHA-1 PCR bank.
./eltt2 -l sha256 Allocate SHA-256 PCR bank.
./eltt2 -l sha384 Allocate SHA-384 PCR bank.
-r:
With the "-r" command you can read data from a selected SHA-1/256/384 PCR.
For example, use the following command to read data from PCR 23 (0x17):
./eltt2 -r 17 Read data from SHA-1 PCR 23.
or
./eltt2 -r sha1 17 Read data from SHA-1 PCR 23.
./eltt2 -r sha256 17 Read data from SHA-256 PCR 23.
-R:
With the "-R" command you can read data from a selected SHA-256 PCR.
For example, use the following command to read data from PCR 23 (0x17):
./eltt2 -R 17
-s:
With the "-s" command you can hash given data with the SHA-1/256/384 hash
algorithm. This command only allows a limited amount of data to be hashed
(depending on the TPM's maximum input buffer size).
For example, use the following command to hash the byte sequence {0x41,
0x62, 0x43, 0x64}:
./eltt2 -s 41624364 Hash given data with SHA-1 hash algorithm.
or
./eltt2 -s sha1 41624364 Hash given data with SHA-1 hash algorithm.
./eltt2 -s sha256 41624364 Hash given data with SHA-256 hash algorithm.
-S:
With the "-S" command you can hash given data with the SHA-256 hash
algorithm. This command only allows a limited amount of data to be hashed
(depending on the TPM input buffer size).
For example, use the following command to hash the byte sequence {0x41,
0x62, 0x43, 0x64}:
./eltt2 -S 41624364
-t:
With the "-t" command you can issue a TPM selftest. It has 3 options:
./eltt2 -t
or
./eltt2 -t not_full Perform a partial TPM2_Selftest to test previously
untested TPM capabilities.
./eltt2 -t full Perform a full TPM2_Selftest to test all TPM
capabilities.
./eltt2 -t incremental Perform a test of selected algorithms.
-T:
With the "-T" command you can read the results of a previously run selftest.
-u:
With the "-u" command you can issue a TPM startup command. It has 2 options:
./eltt2 -u
or
./eltt2 -u clear send a TPM2_Startup with startup type CLEAR to the TPM.
./eltt2 -u state send a TPM2_Startup with startup type STATE to the TPM.
-z:
With the "-z" command you can reset a selected PCR. Note that you can only
reset PCRs 16 and 23 and that the PCR is going to be reset in both banks
(SHA-1 and SHA-256).
For example, use the following command to reset PCR 23 (0x17):
./eltt2 -z 17
2.2 Examples:
In order to work with the TPM, perform the following steps:
- Send the TPM2_Startup command: ./eltt2 -u
3. If you have questions
If you have any questions or problems, please read the section "FAQ and
Troubleshooting" in this document.
In case you still have questions, contact your local Infineon
Representative.
Further information is available at http://www.infineon.com/tpm.
4. Release Info
This is version 1.1. This version is a general release.
5. FAQ and Troubleshooting
If you encounter any error, please make sure that
- the TPM is properly connected.
- the TPM driver is loaded, i.e. check that "/dev/tpm0" exists. In case of
driver loading problems (e.g. shown by "Error opening device"), reboot
your system and try to load the driver again.
- ELTT2 has been started with root permissions. Please note that ELTT2 needs
root permissions for all commands.
- the TPM is started. (See section 2.2 in this document on how to do this.)
- Trousers do not run anymore. In some cases the Kernel starts Trousers by
booting.
Shut down Trousers by entering the following command:
sudo pkill tcsd
The following list shows the most common errors and their solution:
The ELTT2 response is "Error opening the device.":
- You need to load a TPM driver before you can work with ELTT2.
- You need to start ELTT2 with root permissions.
The ELTT2 responds with error code 0x100.
- You need to send the TPM2_Startup command, or you did send it twice. In
case you have not sent it yet, do so with "./eltt2 -u".
The TPM does not change any of the permanent flags shown by sending the "-g"
command , e.g. after a force clear.
- The TPM requires a reset in order to change any of the permanent flags.
Press the reset button or disconnect the TPM to do so.
The value of a PCR does not change after sending PCR extend or reset.
- With the application permissions you cannot modify every PCR. For more
details, please refer to the description for the different PCR commands
in this file.

File diff suppressed because it is too large Load Diff

View File

@@ -1,634 +0,0 @@
#ifndef _ELTT2_H_
#define _ELTT2_H_
/**
* @brief Infineon Embedded Linux TPM Toolbox 2 (ELTT2) for TPM 2.0
* @details eltt2.h implements all TPM byte commands and the prototype declarations for eltt2.c.
* @file eltt2.h
* @date 2014/06/26
* @copyright Copyright (c) 2014 - 2017 Infineon Technologies AG ( www.infineon.com ).\n
* All rights reserved.\n
* \n
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
* conditions are met:\n
* \n
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.\n
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.\n
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.\n
* \n
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// this is the main page for doxygen documentation.
/** @mainpage Infineon Embedded Linux TPM Toolbox 2 (ELTT2) for TPM 2.0 Documentation
*
* @section Welcome
* Welcome to Infineon TPM 2.0 Software-Tool "Embedded Linux TPM Toolbox 2 (ELTT2)".\n
* \n
* @section Introduction
* ELTT2 is a single file-executable program
* intended for test, diagnosis and basic state changes of the Infineon
* Technologies TPM 2.0.\n
* \n
* @section Copyright
* Copyright (c) 2014 - 2017 Infineon Technologies AG ( www.infineon.com ).\n
* All rights reserved.\n
* \n
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
* conditions are met:\n
* \n
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.\n
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.\n
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.\n
* \n
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <getopt.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <inttypes.h>
//-------------"Defines"-------------
#define TPM_RESP_MAX_SIZE 4096 ///< This is the maximum possible TPM response size in bytes.
#define TPM_REQ_MAX_SIZE 1024 ///< This is the maximum possible TPM request size in bytes. TBD: Find out correct value.
#define ERR_COMMUNICATION -1 ///< Return error check for read and write to the TPM.
#define ERR_BAD_CMD -2 ///< Error code for a bad command line argument or option.
#define TPM_SHA1_DIGEST_SIZE 20 ///< For all SHA-1 operations the digest's size is always 20 bytes.
#define TPM_SHA256_DIGEST_SIZE 32 ///< For all SHA-256 operations the digest's size is always 32 bytes.
#define TPM_SHA384_DIGEST_SIZE 48 ///< For all SHA-384 operations the digest's size is always 48 bytes.
#define TPM_CMD_HEADER_SIZE 10 ///< The size of a standard TPM command header is 10 bytes.
#define TPM_CMD_SIZE_OFFSET 2 ///< The offset of a TPM command's size value is 2 bytes.
#define HEX_BYTE_STRING_LENGTH 2 ///< A byte can be represented by two hexadecimal characters.
#ifndef INT_MAX
#define INT_MAX 0x7FFFFFF ///< The maximum value of a signed 32-bit integer.
#endif
// TPM Return codes
#define TPM_RC_SUCCESS 0x00000000 ///< The response error code for TPM_SUCCESS.
#define TPM_RC_BAD_TAG 0x0000001E ///< The response error code for TPM_RC_BAD_TAG.
#define TPM_RC_SIZE 0x00000095 ///< The response error code for TPM_RC_SIZE.
#define TPM_RC_INITIALIZE 0x00000100 ///< The response error code for TPM_RC_INITIALIZE.
#define TPM_RC_FAILURE 0x00000101 ///< The response error code for TPM_RC_FAILURE.
#define TPM_RC_LOCALITY 0x00000907 ///< The response error code for TPM_RC_LOCALITY.
#define FU_FIRMWARE_VALID_FLAG 4 ///< If this flag is set, the firmware is valid.
#define FU_OWNER_FLAG 1 ///< If this flag is set, the owner is set.
// print_response_buf options
#define PRINT_RESPONSE_CLEAR 1 ///< Prints response unformatted.
#define PRINT_RESPONSE_HEADERBLOCKS 2 ///< Prints response in commented blocks.
#define PRINT_RESPONSE_HEX_BLOCK 3 ///< Prints response in rows of 16 bytes and shows the line number.
#define PRINT_RESPONSE_HASH 4 ///< Prints response of Hash
#define PRINT_RESPONSE_WITHOUT_HEADER 12 ///< Prints the response buffer from byte 12.
#define PRINT_RESPONSE_HASH_WITHOUT_HEADER 16 ///< Prints the response buffer from byte 16.
#define PRINT_RESPONSE_WITH_HEADER 0 ///< Prints the response buffer from byte 0.
#define PRINT_RESPONSE_PCR_WITHOUT_HEADER 30 ///< Prints the pcr buffer from pcr_read.
// time conversion
#define YEAR_SECONDS 31536000 ///< Number of seconds in one year
#define DAY_SECONDS 86400 ///< Number of seconds in one day
#define HOUR_SECONDS 3600 ///< Number of seconds in one hour
#define MINUTE_SECONDS 60 ///< Number of seconds in one minute
#define MILISECOND_TO_SECOND 1000 ///< Convertion from miliseconds to seconds
// hash
#define STD_CC_HASH_SIZE 18 ///< Hash command size
// TPM_PT constants
#define PT_FIXED_SELECTOR 1 ///< Fixed GetCapability Flags
#define PT_VAR_SELECTOR 2 ///< Variable GetCapability Flags
//-------------"Macros"-------------
// Null pointer check
#define NULL_POINTER_CHECK(x) if (NULL == x) { ret_val = EINVAL; fprintf(stderr, "Error: Invalid argument.\n"); break; } ///< Argument NULL check.
#define MALLOC_ERROR_CHECK(x) if (NULL == x) { ret_val = errno; fprintf(stderr, "Error (re)allocating memory.\n"); break; } ///< Malloc error check.
#define MEMSET_FREE(x, y) if (NULL != x) { memset(x, 0, y); free(x); x = NULL; } ///< Sets memory to 0, frees memory and sets pointer to NULL.
// Return value check
#define RET_VAL_CHECK(x) if (EXIT_SUCCESS != x) { break; } ///< Return value check
// Command line option parser for hash algorithm
#define HASH_ALG_PARSER(o, c) \
do { \
if (o == option) \
{ \
if (c == argc) \
{ \
hash_algo = ALG_SHA1; \
} \
else \
{ \
if (0 == strcasecmp(optarg, "sha1")) \
{ \
hash_algo = ALG_SHA1; \
} \
else if (0 == strcasecmp(optarg, "sha256")) \
{ \
hash_algo = ALG_SHA256; \
} \
else if (0 == strcasecmp(optarg, "sha384")) \
{ \
hash_algo = ALG_SHA384; \
} \
else \
{ \
ret_val = ERR_BAD_CMD; \
fprintf(stderr, "Unknown option. Use '-h' for more information.\n"); \
break; \
} \
if (argc > optind) \
{ \
optarg = argv[optind++]; \
} \
} \
} \
else \
{ \
hash_algo = ALG_SHA256; \
} \
} while (0)
//--------------"Enums"--------------
// Hash algorithms
typedef enum hash_algo_enum
{
ALG_NULL,
ALG_SHA1,
ALG_SHA256,
ALG_SHA384,
} hash_algo_enum;
//-------------"Methods"-------------
/**
* @brief Convert (max.) 8 byte buffer to an unsigned 64-bit integer.
* @param [in] *input_buffer Input buffer. Make sure that its size is at least as high as offset + length.
* @param [in] offset Start byte for conversion.
* @param [in] length Amount of bytes to be converted.
* @param [out] *output_value Return the converted unsigned 64-bit integer.
* @param [in] input_buffer_size Size of input_buffer in bytes.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer or length is greater than 8.
* @retval EXIT_SUCCESS In case of success.
* @date 2014/06/26
*/
static int buf_to_uint64(uint8_t *input_buffer, uint32_t offset, uint32_t length, uint64_t *output_value, uint32_t input_buffer_size);
/**
* @brief Convert a hexadecimal string representation of bytes like "0A1F" and
returns an array containing the actual byte values as an array (e.g. { 0x0A, 0x1F }).
* @param [in] *byte_string Incoming bytes as string.
* @param [out] *byte_values Byte array representation of given input string.
* Must be allocated by caller with the length given in byte_values_size.
* @param [in] byte_values_size Size of byte_values array.
* @return One of the listed return codes.
* @retval EXIT_SUCCESS In case of success.
* @retval EINVAL In case of a NULL pointer.
* @retval value of errno In case parsing error.
* @date 2014/06/26
*/
static int hexstr_to_bytearray(char *byte_string, uint8_t *byte_values, size_t byte_values_size);
/**
* @brief Convert a number to a byte buffer.
* @param [in] input User input.
* @param [in] input_size Size of input data type in bytes.
* @param [out] *output_byte Return buffer for the converted integer.
Must be allocated by the caller with at least a size of 'input_size'.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @date 2014/06/26
*/
static int int_to_bytearray(uint64_t input, uint32_t input_size, uint8_t *output_byte);
/**
* @brief Create the PCR_Extend command.
* @param [in] *pcr_index_str User input string for PCR index.
* @param [in] *pcr_digest_str User input string of value to extend the selected PCR with.
* @param [out] *pcr_cmd_buf Return buffer for the complete command. Must be allocated by caller.
* @param [in] *pcr_cmd_buf_size Size of memory allocated at pcr_cmd_buf in bytes.
* @param [in] hash_algo Set to ALG_SHA1 for extending with SHA-1,
ALG_SHA256 for SHA-256, and ALG_SHA384 for SHA-384.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer or an invalid option.
* @retval EXIT_SUCCESS In case of success.
* @retval ERR_BAD_CMD In case of bad user input.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @date 2014/06/26
*/
static int pcr_extend(char *pcr_index_str, char *pcr_digest_str, uint8_t *pcr_cmd_buf, size_t pcr_cmd_buf_size, hash_algo_enum hash_algo);
/**
* @brief Create the PCR_Allocate command.
* @param [out] *pcr_cmd_buf Return buffer for the complete command.
* @param [in] hash_algo Set to ALG_SHA1 to allocate SHA-1,
ALG_SHA256 for SHA-256, and ALG_SHA384 for SHA-384.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer or an invalid option.
* @retval EXIT_SUCCESS In case of success.
* @date 2022/05/09
*/
static int pcr_allocate(uint8_t *pcr_cmd_buf, hash_algo_enum hash_algo);
/**
* @brief Create the PCR_Read command.
* @param [in] *pcr_index_str User input string for PCR index.
* @param [out] *pcr_cmd_buf Return buffer for the complete command.
* @param [in] hash_algo Set to ALG_SHA1 for reading with SHA-1,
ALG_SHA256 for SHA-256, and ALG_SHA384 for SHA-384.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer or an invalid option.
* @retval EXIT_SUCCESS In case of success.
* @retval ERR_BAD_CMD In case of bad user input.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @date 2014/06/26
*/
static int pcr_read(char *pcr_index_str, uint8_t *pcr_cmd_buf, hash_algo_enum hash_algo);
/**
* @brief Create the PCR_Reset command.
* @param [in] *pcr_index_str User input string for PCR index.
* @param [out] *pcr_cmd_buf Return buffer for the complete command.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval ERR_BAD_CMD In case of bad user input.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @date 2014/06/26
*/
static int pcr_reset(char *pcr_index_str, uint8_t *pcr_cmd_buf);
/**
* @brief Print the command line usage and switches.
* @date 2014/06/26
*/
static void print_help();
/**
* @brief Print the response buffer in different formats.
* @param [in] *response_buf TPM response.
* @param [in] resp_size TPM response size.
* @param [in] offset Starting point for printing buffer.
* @param [in] format Select the output format.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer or an unknown output format has been transfered.
* @retval EXIT_SUCCESS In case of success.
* @retval buf_to_uint64 All error codes from buf_to_uint64.
* @date 2014/06/26
*/
static int print_response_buf(uint8_t *response_buf, size_t resp_size, uint32_t offset, int format);
/**
* @brief Print a TPM response.
* @param [in] *response_buf TPM response.
* @param [in] resp_size TPM response size.
* @param [in] option Defines appearance of output. Can have the following values:\n
- PRINT_RESPONSE_CLEAR
- PRINT_RESPONSE_HEADERBLOCKS
- PRINT_RESPONSE_HEX_BLOCK
- PRINT_RESPONSE_WITHOUT_HEADER
- PRINT_RESPONSE_WITH_HEADER
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval print_response_buf All error codes from print_response_buf.
* @retval print_clock_info All error codes from print_clock_info.
* @retval print_capability_flags All error codes from print_capability_flags.
* @date 2014/06/26
*/
static int response_print(uint8_t *response_buf, size_t resp_size, int option);
/**
* @brief Check a TPM response for errors.
* @param [in] *response_buf TPM response. Must have at least a size of TPM_CMD_HEADER_SIZE bytes.
* @return Returns the TPM return code extracted from the given TPM response or one of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval buf_to_uint64 All error codes from buf_to_uint64.
* @retval EXIT_SUCCESS In case of success.
* @date 2014/06/26
*/
static int return_error_handling(uint8_t *response_buf);
/**
* @brief Transmit TPM command to /dev/tpm0 and get the response.
* @param [in] *buf TPM request.
* @param [in] length TPM request length.
* @param [out] *response TPM response.
* @param [out] *resp_length TPM response length.
* @return One of the listed return codes or the error code stored in the global errno system variable.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @date 2014/06/26
*/
static int tpmtool_transmit(const uint8_t *buf, ssize_t length, uint8_t *response, ssize_t *resp_length);
/**
* @brief Print the capability flags.
* @param [in] *response_buf TPM response.
* @param [in] cap_selector Type of capabilities to print.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval buf_to_uint64 All error codes from buf_to_uint64.
* @date 2014/06/26
*/
static int print_capability_flags(uint8_t *response_buf, uint8_t cap_selector);
/**
* @brief Print the clock info.
* @param [in] *response_buf TPM response.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval buf_to_uint64 All error codes from buf_to_uint64.
* @date 2014/06/26
*/
static int print_clock_info(uint8_t *response_buf);
/**
* @brief Create the get_random command.
* @param [in] *data_length_string User input string for random data length.
* @param [out] *response_buf Return buffer for the complete command.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval ERR_BAD_CMD In case of bad user input.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @date 2014/06/26
*/
static int get_random(char *data_length_string, uint8_t *response_buf);
/**
* @brief Create the simple hash command.
* @param [in] *data_string User input string of data to be hashed.
* @param [in] hash_algo Set to ALG_SHA1 for hashing with SHA-1,
ALG_SHA256 for SHA-256, and ALG_SHA384 for SHA-384.
* @param [out] *hash_cmd_buf Return buffer for the complete command.
* @param [in] hash_cmd_buf_size Return buffer size.
* @return One of the listed return codes.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @retval int_to_bytearray All error codes from int_to_bytearray.
* @date 2014/06/26
*/
static int create_hash(char *data_string, hash_algo_enum hash_algo, uint8_t *hash_cmd_buf, uint32_t hash_cmd_buf_size);
/**
* @brief Create and transmit a sequence of TPM commands for hashing larger amounts of data.
* @param [in] *data_string User input string of data to be hashed.
* @param [in] hash_algo Set to ALG_SHA1 for hashing with SHA-1,
ALG_SHA256 for SHA-256, and ALG_SHA384 for SHA-384.
* @param [out] *tpm_response_buf TPM response.
* @param [out] *tpm_response_buf_size Size of tpm_response_buf.
* @return One of the listed return codes or the error code stored in the global errno system variable.
* @retval EINVAL In case of a NULL pointer.
* @retval EXIT_SUCCESS In case of success.
* @retval value of errno In case of memory allocation error.
* @retval buf_to_uint64 All error codes from buf_to_uint64.
* @retval hexstr_to_bytearray All error codes from hexstr_to_bytearray.
* @retval int_to_bytearray All error codes from int_to_bytearray.
* @retval tpmtool_transmit All error codes from tpmtool_transmit.
* @retval print_response_buf All error codes from print_response_buf
* @date 2014/06/26
*/
static int create_hash_sequence(char *data_string, hash_algo_enum hash_algo, uint8_t *tpm_response_buf, ssize_t *tpm_response_buf_size);
//-------------"command bytes"-------------
static const uint8_t tpm2_startup_clear[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C, // commandSize
0x00, 0x00, 0x01, 0x44, // TPM_CC_Startup
0x00, 0x00 // TPM_SU_CLEAR
};
static const uint8_t tpm2_startup_state[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C, // commandSize
0x00, 0x00, 0x01, 0x44, // TPM_CC_Startup
0x00, 0x01 // TPM_SU_STATE
};
static const uint8_t tpm_cc_shutdown_clear[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C, // commandSize
0x00, 0x00, 0x01, 0x45, // TPM_CC_Shutdown
0x00, 0x00 // TPM_SU_CLEAR
};
static const uint8_t tpm_cc_shutdown_state[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C, // commandSize
0x00, 0x00, 0x01, 0x45, // TPM_CC_Shutdown
0x00, 0x01 // TPM_SU_STATE
};
static const uint8_t tpm2_self_test[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0B, // commandSize
0x00, 0x00, 0x01, 0x43, // TPM_CC_SelfTest
0x00 // fullTest=No
};
static const uint8_t tpm2_self_test_full[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0B, // commandSize
0x00, 0x00, 0x01, 0x43, // TPM_CC_SelfTest
0x01 // fullTest=Yes
};
static const uint8_t tpm_cc_get_test_result[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0A, // commandSize
0x00, 0x00, 0x01, 0x7C // TPM_CC_GetTestResult
};
static const uint8_t tpm2_self_test_incremental[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x2A, // commandSize
0x00, 0x00, 0x01, 0x42, // TPM_CC_IncrementalSelfTest
0x00, 0x00, 0x00, 0x0E, // Count of Algorithm
0x00, 0x01, 0x00, 0x04, // Algorithm two per line
0x00, 0x05, 0x00, 0x06,
0x00, 0x08, 0x00, 0x0A,
0x00, 0x0B, 0x00, 0x14,
0x00, 0x15, 0x00, 0x16,
0x00, 0x17, 0x00, 0x22,
0x00, 0x25, 0x00, 0x43
};
static const uint8_t tpm2_getrandom[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0C, // commandSize
0x00, 0x00, 0x01, 0x7B, // TPM_CC_GetRandom
0x00, 0x00 // bytesRequested (will be set later)
};
static const uint8_t tpm_cc_readclock[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0A, // commandSize
0x00, 0x00, 0x01, 0x81 // TPM_CC_ReadClock
};
static const uint8_t tpm2_getcapability_fixed[] ={
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x16, // commandSize
0x00, 0x00, 0x01, 0x7A, // TPM_CC_GetCapability
0x00, 0x00, 0x00, 0x06, // TPM_CAP_TPM_PROPERTIES (Property Type: TPM_PT)
0x00, 0x00, 0x01, 0x00, // Property: TPM_PT_FAMILY_INDICATOR: PT_GROUP * 1 + 0
0x00, 0x00, 0x00, 0x66 // PropertyCount 102 (from 100 - 201)
};
static const uint8_t tpm2_getcapability_var[] ={
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x16, // commandSize
0x00, 0x00, 0x01, 0x7A, // TPM_CC_GetCapability
0x00, 0x00, 0x00, 0x06, // TPM_CAP_TPM_PROPERTIES (Property Type: TPM_PT)
0x00, 0x00, 0x02, 0x00, // Property: TPM_PT_FAMILY_INDICATOR: PT_GROUP * 2 + 0
0x00, 0x00, 0x00, 0x02 // PropertyCount 02 (from 200 - 201)
};
// Hash
static const uint8_t tpm2_hash[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0e, // commandSize
0x00, 0x00, 0x01, 0x7D, // TPM_CC_Hash
0x00, 0x00, // size (will be set later)
// buffer (will be added later)
0x00, 0x00, // hashAlg (will be added later)
0x00, 0x00, 0x00, 0x00 // hierarchy of the ticket (TPM_RH_NULL; will be added later)
};
// HashSequence
static uint8_t tpm2_hash_sequence_start[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x0e, // commandSize
0x00, 0x00, 0x01, 0x86, // TPM_CC_HashSequenceStart
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x00 // hashAlg (will be set later)
};
static uint8_t tpm2_sequence_update[] = {
0x80, 0x02, // TPM_ST_SESSIONS
0x00, 0x00, 0x00, 0x00, // commandSize (will be set later)
0x00, 0x00, 0x01, 0x5c, // TPM_CC_SequenceUpdate
0x00, 0x00, 0x00, 0x00, // sequenceHandle (will be set later)
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x09, // authSize (password authorization session)
0x40, 0x00, 0x00, 0x09, // TPM_RS_PW (indicate a password authorization session)
0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00 // size (will be set later)
// buffer (will be added later)
};
static uint8_t tpm2_sequence_complete[] = {
0x80, 0x02, // TPM_ST_SESSIONS
0x00, 0x00, 0x00, 0x21, // commandSize
0x00, 0x00, 0x01, 0x3e, // TPM_CC_SequenceComplete
0x00, 0x00, 0x00, 0x00, // sequenceHandle (will be set later)
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x09, // authSize (password authorization session)
0x40, 0x00, 0x00, 0x09, // TPM_RS_PW (indicate a password authorization session)
0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, // size (NULL buffer)
// null (indicate an empty buffer buffer)
0x40, 0x00, 0x00, 0x07 // hierarchy of the ticket (TPM_RH_NULL)
};
static const uint8_t sha1_alg[] = {
0x00, 0x04 // command for sha1 alg
};
static const uint8_t sha256_alg[] = {
0x00, 0x0B // command for sha256 alg
};
static const uint8_t sha384_alg[] = {
0x00, 0x0C // command for sha384 alg
};
static const uint8_t tpm_cc_hash_hierarchy[] = {
0x40, 0x00, 0x00, 0x07 // hierarchy of the ticket (TPM_RH_NULL)
};
//PCR_Command
static const uint8_t tpm2_pcr_allocate[] = {
0x80, 0x02, // TPM_ST_SESSIONS
0x00, 0x00, 0x00, 0x31, // commandSize
0x00, 0x00, 0x01, 0x2B, // TPM_CC_PCR_Allocate
0x40, 0x00, 0x00, 0x0C, // TPM_RH_PLATFORM
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x09, // authSize (password authorization session)
0x40, 0x00, 0x00, 0x09, // TPM_RS_PW (indicate a password authorization session)
0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, // count (TPML_PCR_SELECTION)
0x00, 0x04, // hash (TPMS_PCR_SELECTION; SHA-1)
0x03, // sizeofSelect (TPMS_PCR_SELECTION)
0x00, 0x00, 0x00, // pcrSelect (TPMS_PCR_SELECTION; will be set later)
0x00, 0x0B, // hash (TPMS_PCR_SELECTION; SHA-256)
0x03, // sizeofSelect (TPMS_PCR_SELECTION)
0x00, 0x00, 0x00, // pcrSelect (TPMS_PCR_SELECTION; will be set later)
0x00, 0x0C, // hash (TPMS_PCR_SELECTION; SHA-384)
0x03, // sizeofSelect (TPMS_PCR_SELECTION)
0x00, 0x00, 0x00 // pcrSelect (TPMS_PCR_SELECTION; will be set later)
};
static const uint8_t tpm2_pcr_read[] = {
0x80, 0x01, // TPM_ST_NO_SESSIONS
0x00, 0x00, 0x00, 0x14, // commandSize
0x00, 0x00, 0x01, 0x7E, // TPM_CC_PCR_Read
0x00, 0x00, 0x00, 0x01, // count (TPML_PCR_SELECTION)
0x00, 0x00, // hash (TPMS_PCR_SELECTION; will be set later)
0x03, // sizeofSelect (TPMS_PCR_SELECTION)
0x00, 0x00, 0x00 // pcrSelect (TPMS_PCR_SELECTION)
};
static const uint8_t tpm2_pcr_extend[] = {
0x80, 0x02, // TPM_ST_SESSIONS
0x00, 0x00, 0x00, 0x00, // commandSize (will be set later)
0x00, 0x00, 0x01, 0x82, // TPM_CC_PCR_Extend
0x00, 0x00, 0x00, 0x00, // {PCR_FIRST:PCR_LAST} (TPMI_DH_PCR)
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x09, // authSize (password authorization session)
0x40, 0x00, 0x00, 0x09, // TPM_RS_PW (indicate a password authorization session)
0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, // count (TPML_DIGEST_VALUES)
0x00, 0x00 // hashAlg (TPMT_HA; will be set later)
// digest (TPMT_HA; will be added later)
};
static const uint8_t tpm2_pcr_reset[] = {
0x80, 0x02, // TPM_ST_SESSIONS
0x00, 0x00, 0x00, 0x1B, // commandSize
0x00, 0x00, 0x01, 0x3D, // TPM_CC_PCR_Reset
0x00, 0x00, 0x00, 0x00, // {PCR_FIRST:PCR_LAST} (TPMI_DH_PCR)
0x00, 0x00, // authSize (NULL Password)
// null (indicate a NULL Password)
0x00, 0x09, // authSize (password authorization session)
0x40, 0x00, 0x00, 0x09, // TPM_RS_PW (indicate a password authorization session)
0x00, 0x00, 0x01, 0x00, 0x00
};
#endif /* _ELTT2_H_ */

View File

@@ -1,29 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hfcl
PKG_VERSION:=1.0
PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/hfcl
SECTION:=base
CATEGORY:=Utilities
TITLE:=hfcl
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile/Default
endef
Build/Compile = $(Build/Compile/Default)
define Package/hfcl/install
cp -rf ./files/* $(1)
endef
$(eval $(call BuildPackage,hfcl))

View File

@@ -1,43 +0,0 @@
#!/bin/sh
echo "Start Websocket check/recovery script"
ucentral_conn=$(netstat -atulpn | grep -i ucentral | awk '{print $6}')
hostname_AP=$(uci get system.@system[0].hostname)
uc_file_check=$(du /etc/config/ucentral | awk '{print $1}' )
sleep 20
curr_date=$(date)
if [[ "$uc_file_check" = 0 ]]
then
echo "[[$curr_date]] empty ucentral file found, need to factory reset"
ubi_mount=$(mount | grep ubifs | grep noatime | awk '{print $1}')
if [[ "$ubi_mount" != "/dev/ubi0_3" ]]
then
echo "[[$curr_date]] ubifs not mounted, need to reboot before factory reset, mount was $ubi_mount"
/sbin/reboot
else
/sbin/jffs2reset -y -r
fi
elif [[ "$hostname_AP" = "OpenWrt" ]]
then
echo "[[$curr_date]] hostname set to openwrt, doing ucentral and capabilities load"
/usr/share/ucentral/capabilities.uc
rlink=$(readlink -f /etc/ucentral/ucentral.active)
/usr/share/ucentral/ucentral.uc /etc/ucentral/ucentral.active
rm -rf /etc/ucentral/ucentral.active
ln -s $rlink /etc/ucentral/ucentral.active
sleep 60
ucentral_check=$(netstat -atulpn | grep -i ucentral | awk '{print $6}')
if [[ "$ucentral_check" != "ESTABLIHED" ]]
then
echo "[[$curr_date]] loading didn't work, need to factory reset"
/sbin/jffs2reset -y -r
fi
elif [[ "$ucentral_conn" != "ESTABLISHED" ]]
then
echo "[[$curr_date]] Ucentral either crashed or stopped, restarting the same"
/etc/init.d/ucentral restart
else
echo "[[$curr_date]] Ucentral working all fine, nothing to do"
fi

View File

@@ -1,18 +0,0 @@
#!/bin/sh
#rm -f /etc/rc.local
#cp -f /etc/loop.local /etc/rc.local
crontab -r
/etc/init.d/cron enable
/etc/init.d/cron start
sleep 60
crontab -l | { cat; echo "*/3 * * * * /bin/sh /etc/ucentral_check.sh >> /tmp/ucentral_check";} | crontab -
crontab -l | { cat; echo "* */4 * * * rm -rf /tmp/ucentral_check";} | crontab -
/etc/init.d/cron restart

View File

@@ -11,7 +11,7 @@ PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2023-09-08
PKG_SOURCE_VERSION:=e5ccbfc69ecf297590341ae8b461edba9d8e964c
PKG_MIRROR_HASH:=fcc6550f46c7f8bbdbf71e63f8f699b9a0878565ad1b90a17855f5ec21283b8f
PKG_MIRROR_HASH:=4d71097b8e3b91b5c21c2bba7a1e68415bd21d972fddbffa9ef130877d81b347
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=BSD-3-Clause
@@ -150,7 +150,7 @@ define Package/hostapd/Default
TITLE:=IEEE 802.1x Authenticator
URL:=http://hostap.epitest.fi/
DEPENDS:=$(DRV_DEPENDS) +hostapd-common $(CORE_DEPENDS)
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-$(PKG_RELEASE))
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-r$(PKG_RELEASE))
USERID:=network=101:network=101
PROVIDES:=hostapd
CONFLICTS:=$(HOSTAPD_PROVIDERS)
@@ -255,7 +255,7 @@ define Package/wpad/Default
SUBMENU:=WirelessAPD
TITLE:=IEEE 802.1x Auth/Supplicant
DEPENDS:=$(DRV_DEPENDS) +hostapd-common $(CORE_DEPENDS)
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-$(PKG_RELEASE))
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-r$(PKG_RELEASE))
USERID:=network=101:network=101
URL:=http://hostap.epitest.fi/
PROVIDES:=hostapd wpa-supplicant
@@ -400,7 +400,7 @@ define Package/wpa-supplicant/Default
TITLE:=WPA Supplicant
URL:=http://hostap.epitest.fi/wpa_supplicant/
DEPENDS:=$(DRV_DEPENDS) +hostapd-common $(CORE_DEPENDS)
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-$(PKG_RELEASE))
EXTRA_DEPENDS:=hostapd-common (=$(PKG_VERSION)-r$(PKG_RELEASE))
USERID:=network=101:network=101
PROVIDES:=wpa-supplicant
CONFLICTS:=$(SUPPLICANT_PROVIDERS)

View File

@@ -0,0 +1,14 @@
--- a/hostapd/ctrl_iface.c 2025-09-24 14:15:25.135668867 +0800
+++ b/hostapd/ctrl_iface.c 2025-09-24 15:32:46.082317382 +0800
@@ -2657,6 +2657,11 @@ static int hostapd_ctrl_iface_chan_switc
break;
}
+ /* Initialize HT/VHT/HE parameters */
+ settings.freq_params.ht_enabled = iface->conf->ieee80211n;
+ settings.freq_params.vht_enabled = iface->conf->ieee80211ac;
+ settings.freq_params.he_enabled = iface->conf->ieee80211ax;
+
if (settings.freq_params.center_freq1)
dfs_range += hostapd_is_dfs_overlap(
iface, bandwidth, settings.freq_params.center_freq1);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,53 +0,0 @@
From 375d0d25e6c02991392e44956c81cbac84909f49 Mon Sep 17 00:00:00 2001
From: Venkat Chimata <venkat@nearhop.com>
Date: Thu, 4 Sep 2025 00:09:17 +0530
Subject: [PATCH] wifi: ap: mitigate peer-delete WMI timeout to reduce blind
period & prevent peer leaks
1. When a connected client roams to another AP, the AP is trying to delete the peer
but for some reason the WMI command times out and while driver is waiting for
the response, we observed that the AP doesn't respond to any frames from STA
(probe requests, authentication etc) and once the response times out (3seconds default)
then AP starts responding to the older requets but client has already connected to
another AP. As the root cause for the response timing out is in the FW, we added
a WAR to reduce the timeout to minimize this blind period, with this AP responds
after 100ms and client connects successfully. And 100ms timeout is also reasonable
for this internal operation.
2. In case of peer deletion timeout, the driver peer database is not cleared, so,
if this happens often (which it is) then eventually we hit the max peers in the
driver and all subsequent operations fail, so, in case of timeout ignore the failure
and proceed with driver peer database cleanup.
Signed-off-by: Venkat Chimata <venkat@nearhop.com>
---
drivers/net/wireless/ath/ath11k/peer.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/peer.c b/drivers/net/wireless/ath/ath11k/peer.c
index 1907067..aefc6ba 100644
--- a/drivers/net/wireless/ath/ath11k/peer.c
+++ b/drivers/net/wireless/ath/ath11k/peer.c
@@ -771,7 +771,7 @@ int ath11k_wait_for_peer_delete_done(struct ath11k *ar, u32 vdev_id,
}
time_left = wait_for_completion_timeout(&ar->peer_delete_done,
- 3 * HZ);
+ 100 * HZ / 1000);
if (time_left == 0) {
ath11k_warn(ar->ab, "Timeout in receiving peer delete response\n");
return -ETIMEDOUT;
@@ -857,7 +857,10 @@ int ath11k_peer_delete(struct ath11k *ar, u32 vdev_id, u8 *addr)
}
ret = ath11k_wait_for_peer_delete_done(ar, vdev_id, addr);
- if (ret)
+ /* WAR: For the timeout case, proceed to delete the peer anyway, as FW is
+ * still functional, without this, driver ends up hitting max peers
+ */
+ if (ret && ret != -ETIMEDOUT)
return ret;
ATH11K_MEMORY_STATS_DEC(ar->ab, per_peer_object,
--
2.34.1

View File

@@ -1,157 +0,0 @@
#
# Copyright (C) 2023 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mcu-firmware
PKG_VERSION:=2023-03-12
PKG_RELEASE:=1
PKG_MAINTAINER:=Piotr Dymacz <pepe2k@gmail.com>
include $(INCLUDE_DIR)/package.mk
define Package/mcu-fw-default
CATEGORY:=Firmware
SUBMENU:=MCU firmware
SECTION:=firmware
TITLE:=MCU firmware
endef
# Zephyr versions
# 4 fields separated with underscore:
# version-name_git-sha_pipeline-id_sha256-of-package
ZEPHYR_VERSIONS := \
zephyr-v3.3.x_7055d10e538e_3877473859_321a0daf6328698a913c6504d19aa85a5170dfce6039b86d31d2e9162d34af7c \
zephyr-main_cf50a3c570bb_3912606668_10922f34cdde9e16cbee76a13a14fb935b9d1fe13eb9136cba31de27033a9c3e
ZEPHYR_FW_CI_URL := https://gitlab.com/pepe2k/zephyr/-/jobs/
ZEPHYR_FW_TYPES := \
hello_world \
hci_uart \
hci_usb
# Zephyr 'hello_world' targets
ZEPHYR_HELLO_WORLD_TARGETS := \
cig_wf196_nrf52833 \
edgecore_eap102_nrf52840 \
nrf52840dongle_nrf52840
# Zephyr 'hci_uart' targets
ZEPHYR_HCI_UART_TARGETS:= \
cig_wf196_nrf52833 \
edgecore_eap102_nrf52840 \
nrf52840dongle_nrf52840
# Zephyr 'hci_usb' targets
ZEPHYR_HCI_USB_TARGETS := \
edgecore_eap102_nrf52840 \
nrf52840dongle_nrf52840
word-underscore = $(word $2,$(subst _, ,$1))
define Download/zephyr-fw
URL:=$(ZEPHYR_FW_CI_URL)$(call word-underscore,$(2),3)/
URL_FILE:=artifacts/download?file_type=archive
FILE:=$(call word-underscore,$(2),1)-$(call word-underscore,$(2),2).zip
HASH:=$(call word-underscore,$(2),4)
endef
$(foreach FW,$(ZEPHYR_VERSIONS),$(eval $(call Download,zephyr-fw,$(FW))))
# $(1) firmware name (e.g. hci_usb)
define zephyr-fw-host-support
define Package/zephyr-$(1)-host-support
$(call Package/mcu-fw-default)
DEPENDS:=+mcu
TITLE:=Zephyr '$(1)' common host side support
HIDDEN:=1
endef
define Package/zephyr-$(1)-host-support/install
$(CP) ./files/$(1)/* $$(1)/
endef
endef
# $(1) version (e.g zephyr-v3.3.x)
# $(2) firmware name (e.g. hci_usb)
# $(3) target/board name (e.g. nrf52840dongle_nrf52840)
define zephyr-fw
define Package/$(1)-$(2)-$(3)
$(call Package/mcu-fw-default)
DEPENDS:=+mcu $(call zephyr-fw-deps,$(2))
TITLE:=Zephyr '$(2)'
endef
define Package/$(1)-$(2)-$(3)/description
Zephyr '$(1)' based firmware '$(2)' for '$(3)' board
endef
define Package/$(1)-$(2)-$(3)/install
$(INSTALL_DIR) $$(1)/lib/firmware/mcu/$(3)/$(1)__$(2)
$(INSTALL_DATA) $(PKG_BUILD_DIR)/$(1)/$(3)/$(1)__$(2)/*.bin \
$$(1)/lib/firmware/mcu/$(3)/$(1)__$(2)/
endef
endef
define zephyr-fw-deps
$(if $(wildcard ./files/$(1)/*),+zephyr-$(1)-host-support) \
$(if $(findstring hci_u,$1),+bluez-daemon +kmod-bluetooth +kmod-crypto-user)
endef
define zephyr-fw-unzip
mkdir -p $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1); \
unzip -q -d $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1) \
$(DL_DIR)/$(call word-underscore,$(1),1)-$(call word-underscore,$(1),2).zip; \
for fw in $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1)/*.tar.gz; do \
$(TAR) -C $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1) --one-top-level -xzf $$$$fw; \
rm -rf $$$$fw; \
done;
endef
define Build/Prepare
$(foreach FW,$(ZEPHYR_VERSIONS),$(call zephyr-fw-unzip,$(FW)))
endef
define Build/Compile
endef
# Generate host side support packages (per firmware type)
$(foreach FW,$(ZEPHYR_FW_TYPES),\
$(if $(wildcard ./files/$(FW)/*),$(eval $(call zephyr-fw-host-support,$(FW)))))
$(foreach FW,$(ZEPHYR_FW_TYPES),\
$(if $(wildcard ./files/$(FW)/*),$(eval $(call BuildPackage,zephyr-$(FW)-host-support))))
# Generate dedicated Zephyr firmware packages (per firmware version, type and board)
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HELLO_WORLD_TARGETS),\
$(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hello_world,$(TARGET)))))
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HCI_UART_TARGETS),\
$(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hci_uart,$(TARGET)))))
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HCI_USB_TARGETS),\
$(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hci_usb,$(TARGET)))))
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HELLO_WORLD_TARGETS),\
$(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hello_world-$(TARGET)))))
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HCI_UART_TARGETS),\
$(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hci_uart-$(TARGET)))))
$(foreach VER,$(ZEPHYR_VERSIONS),\
$(foreach TARGET,$(ZEPHYR_HCI_USB_TARGETS),\
$(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hci_usb-$(TARGET)))))

View File

@@ -1,79 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/mcu.sh
attach_hci_controller() {
local section="$1"
local sn
local pid
local interface
local uart_path
local uart_baud
local uart_flow
[ -n "$section" ] || return 1
command -v btattach > /dev/null 2>&1 || return 1
config_load mcu
config_get sn "$section" sn
config_get interface "$section" interface
config_get uart_path "$section" uart_path
config_get uart_baud "$section" uart_baud "115200"
config_get uart_flow "$section" uart_flow "0"
[ -n "$sn" ] || return 1
if [ "$interface" = "usb" ]; then
uart_baud="1000000"
uart_flow="1"
dev_found=""
usb_path="/sys/bus/usb/devices/*"
for dev_path in $usb_path; do
dev="$(basename "$dev_path")"
[[ $dev == *":"* ]] && continue
[ "$sn" = "$(cat "${dev_path}/serial" 2>/dev/null)" ] && {
dev_found="$dev"
break
}
done
[ -n "$dev_found" ] || return 1
usb_path="/sys/bus/usb/devices/${dev_found}*/tty/*"
for tty_path in $usb_path; do
tty="$(basename "$tty_path")"
[ -c "/dev/${tty}" ] && {
uart_path="/dev/${tty}"
break
}
done
fi
[ -c "$uart_path" ] || return 1
# Give MCU some time for BLE controller setup
sleep 1
if [ "$uart_flow" = "1" ]; then
btattach -B "$uart_path" -S "$uart_baud" > /dev/null 2>&1 &
else
btattach -B "$uart_path" -S "$uart_baud" -N > /dev/null 2>&1 &
fi
pid="$!"
kill -0 "$pid" > /dev/null 2>&1 && {
echo "$pid" > "/var/run/mcu.${sn}.pid"
return 0
}
return 1
}
attach_hci_controller "$1" || exit 1
exit 0

View File

@@ -1,50 +0,0 @@
#
# Copyright (C) 2023 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mcu
PKG_VERSION:=2023-03-22
PKG_RELEASE=1
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=
PKG_MAINTAINER:=Piotr Dymacz <pepe2k@gmail.com>
include $(INCLUDE_DIR)/package.mk
define Package/mcu
TITLE:=Generic OpenWrt/OpenWiFi MCU config and management handler
CATEGORY:=Utilities
DEPENDS:=+umcumgr +libubox
SECTION:=utils
endef
define Package/mcu/conffiles
/etc/config/mcu
endef
define Build/Compile
endef
define Package/mcu/install
$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/hotplug.d/usb $(1)/lib/functions $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/mcu.init $(1)/etc/init.d/mcu
$(INSTALL_DATA) ./files/mcu.hotplug $(1)/etc/hotplug.d/usb/30-mcu
$(INSTALL_DATA) ./files/mcu.sh $(1)/lib/functions
$(if $(wildcard ./files/uci-defaults/$(BOARD)_$(SUBTARGET)), \
$(INSTALL_DATA) ./files/uci-defaults/$(BOARD)_$(SUBTARGET) \
$(1)/etc/uci-defaults/20-mcu, \
$(if $(wildcard ./files/uci-defaults/$(BOARD)), \
$(INSTALL_DATA) ./files/uci-defaults/$(BOARD) \
$(1)/etc/uci-defaults/20-mcu \
) \
)
endef
$(eval $(call BuildPackage,mcu))

View File

@@ -1,32 +0,0 @@
config mcu 'uart_no_hw_flow'
option interface 'uart'
option bootloader 'mcuboot'
option enable_pin 'mcu-enable'
option uart_path '/dev/ttyMSM1'
option uart_baud '115200'
option firmware 'zephyr-main__hello_world'
option disabled '1'
config mcu 'uart_with_hw_flow'
option interface 'uart'
option bootloader 'mcuboot'
option enable_pin 'mcu-enable'
option uart_path '/dev/ttyMSM1'
option uart_baud '1000000'
option uart_flow '1'
option firmware 'zephyr-main__hello_world'
option disabled '1'
config mcu 'usb_with_enable_pin'
option interface 'usb'
option bootloader 'mcuboot'
option enable_pin 'mcu-enable'
option firmware 'zephyr-main__hello_world'
option disabled '1'
config mcu 'usb_no_enable_pin'
option interface 'usb'
option bootloader 'mcuboot'
option sn 'ABCDEF1234567890'
option firmware 'zephyr-main__hello_world'
option disabled '1'

View File

@@ -1,142 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/mcu.sh
MCU_SCRIPT_NAME="mcu-hotplug"
MCU_CFG_FOUND="0"
mcu_hotplug_setup() {
local sn
local fw_type
local disabled
local sn_dev="$2"
local uart="$3"
SECT="$1"
MCU_SYSINFO_OUTPUT=""
MCU_IMGLIST_OUTPUT=""
[ "$MCU_CFG_FOUND" = "1" ] && return 0
config_get sn "$SECT" sn
[ "$sn" != "$sn_dev" ] && return 0
MCU_SCRIPT_NAME="mcu-hotplug.${SECT}"
MCU_CFG_FOUND="1"
mcu_logi "found matching config section '$SECT'"
# Section disabled?
config_get_bool disabled "$SECT" disabled "0"
[ "$disabled" = "1" ] && {
mcu_logw "section is disabled in config"
return 0
}
# Stop related service
[ -f "/var/run/mcu.${sn}.pid" ] && {
kill "$(cat "/var/run/mcu.${sn}.pid" 2>/dev/null)" \
> /dev/null 2>&1
rm -f "/var/run/mcu.${sn}.pid" > /dev/null 2>&1
}
mcu_sn_check_and_update "$sn" "$uart"
[ $? -ne 0 ] && return 1
mcu_fw_check_and_update "$uart"
rc="$?"
[ "$rc" = "1" ] && return 1
[ "$rc" = "0" ] && {
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" ] || return 0
[ -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
}
return 0
}
# We are looking for ttyACM with specific product name and USB VID:PID
[ "$ACTION" = "add" -a \
"$DRIVER" = "cdc_acm" -a \
"$DEVTYPE" = "usb_interface" ] && {
usb_path="/sys/bus/usb/devices/"
dev="$(echo "$DEVICENAME" | cut -d ':' -f 1)"
[ -n "$dev" ] || return 1
p="$(cat "${usb_path}/${dev}/product" 2>/dev/null)"
id="$(cat "${usb_path}/${dev}/idVendor" 2>/dev/null)"
id="${id}$(cat "${usb_path}//${dev}/idProduct" 2>/dev/null)"
sn="$(cat "${usb_path}/${dev}/serial" 2>/dev/null)"
[ "$p" = "$MCUBOOT_USB_PRODUCT" -a \
"$id" = "$MCUBOOT_USB_VID_PID" ] || return 0
mcu_logi "found compatible MCU with S/N '$sn' at USB bus '$dev'"
# We expect just a single ttyACM interface
usb_path="/sys/bus/usb/devices/${dev}*/tty/*"
for tty in $usb_path; do
[ -c "/dev/$(basename "$tty")" ] && {
uart_path="/dev/$(basename "$tty")"
break
}
done
[ -n "$uart_path" ] || {
mcu_loge "failed to find ttyACM interface"
return 1
}
# Try to acquire lock (init script might be handling this device)
exec 9>"$MCU_FLOCK_FILE" || return 1
flock -n 9 || {
mcu_logd "lock taken by init script, skipping"
return 1
}
config_load mcu
config_foreach mcu_hotplug_setup mcu "$sn" "$uart_path"
# Add new config section for this MCU if no matching found (by S/N)
[ "$MCU_CFG_FOUND" = "0" ] && {
MCU_SCRIPT_NAME="mcu-hotplug"
sect="${sn:0:8}_usb"
mcu_logi "no matching MCU config found, adding new (disabled): '$sect'"
[ -d /etc/config-shadow ] && {
uci -c /etc/config-shadow -q batch <<-EOF
set mcu.${sect}=mcu
set mcu.${sect}.interface=usb
set mcu.${sect}.bootloader=mcuboot
set mcu.${sect}.sn=$sn
set mcu.${sect}.disabled=1
EOF
uci -c /etc/config-shadow -q commit mcu
}
uci -q batch <<-EOF
set mcu.${sect}=mcu
set mcu.${sect}.interface=usb
set mcu.${sect}.bootloader=mcuboot
set mcu.${sect}.sn=$sn
set mcu.${sect}.disabled=1
EOF
uci -q commit mcu
flock -u 9
return 0
}
flock -u 9
}

View File

@@ -1,309 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
. /lib/functions/mcu.sh
SECT=
mcu_setup_uart() {
local uart="$1"
local baud="$2"
local flow="$3"
local gpio_path="$4"
local gpio_on="$5"
local sn="$6"
local fw_type
# Take out MCU out of reset and read basic info
mcu_enable_pin_set "$gpio_path" "$gpio_on"
sleep 1
mcu_sn_check_and_update "$sn" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
mcu_fw_check_and_update "$uart" "$baud" "$flow"
rc="$?"
[ "$rc" = "1" ] && return 1
[ "$rc" = "2" ] && {
sleep 1
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
}
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" ] || return 0
[ -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
}
mcu_setup_usb() {
local gpio_path="$1"
local gpio_on="$2"
local sn="$3"
local gpio_off="0"
local uart
local fw_type
[ "$gpio_on" = "0" ] && gpio_off="1"
# If we have S/N in config, only take out the MCU from reset
[ -n "$sn" ] && {
mcu_logi "MCU S/N already set, hotplug will perform config"
mcu_enable_pin_set "$gpio_path" "$gpio_on"
return 0
}
# If S/N is missing, we need to take out MCU from reset, find out
# its S/N and save it for later
exec 9>"$MCU_FLOCK_FILE" || {
mcu_loge "failed to obtain lock (exec fail)!"
return 1
}
flock -n 9 || {
mcu_loge "failed to obtain lock (flock fail)!"
return 1
}
usb_path="/sys/bus/usb/devices/*"
devs_old=""
for dev_path in $usb_path; do
dev="$(basename "$dev_path")"
[[ $dev == *":"* ]] && continue
p="$(cat "${dev_path}/product" 2>/dev/null)"
id="$(cat "${dev_path}/idVendor" 2>/dev/null)"
id="${id}$(cat "${dev_path}/idProduct" 2>/dev/null)"
[ "$p" = "$MCUBOOT_USB_PRODUCT" -a \
"$id" = "$MCUBOOT_USB_VID_PID" ] && \
devs_old="$devs_old $dev"
done
mcu_enable_pin_set "$gpio_path" "$gpio_on"
sleep 2
dev_found=""
for dev_path in $usb_path; do
dev="$(basename "$dev_path")"
[[ $dev == *":"* ]] && continue
p="$(cat "${dev_path}/product" 2>/dev/null)"
id="$(cat "${dev_path}/idVendor" 2>/dev/null)"
id="${id}$(cat "${dev_path}/idProduct" 2>/dev/null)"
[ "$p" = "$MCUBOOT_USB_PRODUCT" -a \
"$id" = "$MCUBOOT_USB_VID_PID" ] && {
[ -n "$devs_old" ] && {
if echo "$devs_old" | grep -q "$dev"; then
continue
fi
}
dev_found="$dev"
break
}
done
[ -n "$dev_found" ] || {
mcu_loge "failed to find MCU on USB bus"
mcu_enable_pin_set "$gpio_path" "$gpio_off"
flock -u 9
return 1
}
mcu_logd "MCU found on USB bus: '$dev_found'"
# We expect just a single ttyACM interface
usb_path="/sys/bus/usb/devices/${dev_found}*/tty/*"
for tty_path in $usb_path; do
tty="$(basename "$tty_path")"
[ -c "/dev/${tty}" ] && {
uart="/dev/${tty}"
break
}
done
[ -n "$uart" ] || {
mcu_loge "failed to find ttyACM interface"
mcu_enable_pin_set "$gpio_path" "$gpio_off"
flock -u 9
return 1
}
mcu_sn_check_and_update "$sn" "$uart"
[ $? -ne 0 ] && {
mcu_enable_pin_set "$gpio_path" "$gpio_off"
flock -u 9
return 1
}
mcu_fw_check_and_update "$uart"
rc="$?"
[ "$rc" = "1" ] && {
mcu_enable_pin_set "$gpio_path" "$gpio_off"
flock -u 9
return 1
}
[ "$rc" = "0" ] && {
fw_type="$(uci -q get "mcu.${SECT}.firmware" | awk -F '__' '{print $2}')"
[ -n "$fw_type" -a -x "${MCU_HS_DIR}/${fw_type}.sh" ] && \
"${MCU_HS_DIR}/${fw_type}.sh" "$SECT"
}
flock -u 9
}
mcu_setup() {
local sn
local action
local fw_type
local disabled
local uart_baud
local uart_flow
local uart_path
local interface
local bootloader
local enable_pin
local gpio_path
local gpio_on="1"
local gpio_off="0"
SECT="$1"
MCU_SCRIPT_NAME="mcu-init.${SECT}"
action="$2"
MCU_SYSINFO_OUTPUT=""
MCU_IMGLIST_OUTPUT=""
# Section disabled?
[ "$action" = "start" ] && {
config_get_bool disabled "$SECT" disabled "0"
[ "$disabled" = "1" ] && {
mcu_logw "section is disabled in config"
return 0
}
}
config_get sn "$SECT" sn
config_get bootloader "$SECT" bootloader
config_get enable_pin "$SECT" enable_pin
config_get interface "$SECT" interface
config_get uart_path "$SECT" uart_path
config_get uart_baud "$SECT" uart_baud "115200"
config_get_bool uart_flow "$SECT" uart_flow "0"
# Stop related service
[ "$action" = "stop" ] && {
[ -n "$sn" -a -f "/var/run/mcu.${sn}.pid" ] && {
kill "$(cat "/var/run/mcu.${sn}.pid" 2>/dev/null)" \
> /dev/null 2>&1
rm -f "/var/run/mcu.${sn}.pid" > /dev/null 2>&1
}
}
# As for now, only 'mcuboot' bootloader is supported
case "$bootloader" in
"mcuboot")
command -v umcumgr > /dev/null 2>&1 || {
mcu_loge "missing 'umcumgr' tool"
return 1
}
;;
*)
mcu_loge "unsupported or unset 'bootloader' option"
return 1
;;
esac
# Verify 'enable_pin' option
if [ -z "$enable_pin" ]; then
# USB based MCU without GPIO based way for reset are fully
# handled by the hotplug script
[ "$interface" = "usb" ] && {
mcu_logw "'enable_pin' option is unset, ignoring"
return 0
}
[ "$interface" = "uart" ] && {
mcu_loge "'enable_pin' option is unset"
return 1
}
else
gpio_path="/sys/class/gpio/${enable_pin}"
[ -d "$gpio_path" ] || {
mcu_loge "invalid 'enable_pin' option"
return 1
}
[ "$(cat "${gpio_path}/active_low")" = "1" ] && {
gpio_on="0"
gpio_off="1"
}
# TODO: should we maybe bail out here if the MCU was took out
# of reset already before, by something/someone else?
[ "$(cat "${gpio_path}/value")" = "$gpio_on" ] && {
if [ "$action" = "start" ]; then
mcu_logw "MCU already enabled, resetting"
else
mcu_logi "disabling MCU"
fi
mcu_enable_pin_set "$gpio_path" "$gpio_off"
sleep 1
}
fi
[ "$action" = "stop" ] && return 0
# For now only 'usb' and 'uart' interfaces are supported
case "$interface" in
"uart")
[ -z "$uart_path" -o ! -c "$uart_path" ] && {
mcu_loge "invalid or unset 'uart_path' option"
return 1
}
mcu_setup_uart "$uart_path" "$uart_baud" "$uart_flow" \
"$gpio_path" "$gpio_on" "$sn"
;;
"usb")
mcu_setup_usb "$gpio_path" "$gpio_on" "$sn"
;;
*)
mcu_loge "unsupported or unset 'interface' option"
return 1
;;
esac
}
start() {
config_load mcu
config_foreach mcu_setup mcu "start"
return 0
}
stop() {
config_load mcu
config_foreach mcu_setup mcu "stop"
return 0
}

View File

@@ -1,501 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
# Product name and VID:PID used by OpenWrt/OpenWiFi MCUboot fork
MCUBOOT_USB_PRODUCT="MCUboot serial recovery"
MCUBOOT_USB_VID_PID="16c005e1"
# Host support and firmware directories
MCU_HS_DIR="/etc/mcu.d"
MCU_FW_DIR="/lib/firmware/mcu"
MCU_FLOCK_FILE="/tmp/lock/mcu"
MCU_SYSINFO_OUTPUT=
MCU_IMGLIST_OUTPUT=
MCU_SCRIPT_NAME=""
# logger helpers
mcu_log() {
if [ -n "$MCU_SCRIPT_NAME" ]; then
logger -p "$1" -t "${MCU_SCRIPT_NAME}[$$]" "$2"
else
logger -p "$1" "$2"
fi
}
mcu_loge() {
mcu_log "err" "$1"
}
mcu_logd() {
mcu_log "debug" "$1"
}
mcu_logi() {
mcu_log "info" "$1"
}
mcu_logn() {
mcu_log "notice" "$1"
}
mcu_logw() {
mcu_log "warn" "$1"
}
mcu_fetch_fwlist() {
local uart="$1"
local baud="$2"
local flow="$3"
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
[ -n "$MCU_IMGLIST_OUTPUT" ] && return 0
MCU_IMGLIST_OUTPUT="$(umcumgr -s -d "$uart" -b "$baud$flow" list)"
[ $? -eq 0 ] || {
mcu_loge "request 'list' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
}
mcu_fetch_sysinfo() {
local uart="$1"
local baud="$2"
local flow="$3"
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
[ -n "$MCU_SYSINFO_OUTPUT" ] && return 0
MCU_SYSINFO_OUTPUT="$(umcumgr -s -d "$uart" -b "$baud$flow" sysinfo)"
[ $? -eq 0 ] || {
mcu_loge "request 'sysinfo' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
}
mcu_get() {
local param="$1"
local slot="$2"
local value
local metadata
local sysinfo_field
case "$param" in
"board"|\
"soft_ver"|\
"serial_num"|\
"active_slot")
sysinfo_field="$param"
;;
"slots_num")
sysinfo_field="single_slot"
;;
"fwname")
[ -n "$slot" ] || return 1
param="image list: slot${slot} fw_name"
metadata="$(echo "$MCU_IMGLIST_OUTPUT" | grep "slot${slot}_metadata=" | cut -d '=' -f 2)"
[ -n "$metadata" ] && {
json_load "$metadata"
json_get_var value fw_name
}
;;
"fwsha")
[ -n "$slot" ] || return 1
param="image list: slot${slot}_hash"
value="$(echo "$MCU_IMGLIST_OUTPUT" | grep "slot${slot}_hash=" | cut -d '=' -f 2)"
;;
*)
return 1
;;
esac
[ -n "$sysinfo_field" ] && {
value="$(echo "$MCU_SYSINFO_OUTPUT" | grep "${sysinfo_field}=" | cut -d '=' -f 2)"
[ "$sysinfo_field" = "single_slot" ] && {
[ -n "$value" ] || value="1"
[ "$value" != "1" ] && value="2"
}
param="sysinfo: $param"
}
[ -n "$value" ] && mcu_logd "$param: '$value'"
echo "$value"
}
mcu_req() {
local cmd="$1"
local uart="$2"
local baud="$3"
local flow="$4"
case "$cmd" in
"boot"|\
"reset")
;;
*)
return 1
;;
esac
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
umcumgr -s -d "$uart" -b "$baud$flow" "$cmd" || {
mcu_loge "request '$cmd' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
mcu_logi "MCU requested '$cmd'"
}
mcu_sel_slot() {
local slot="$1"
local uart="$2"
local baud="$3"
local flow="$4"
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
# Request firmware active slot change
umcumgr -s -d "$uart" -b "$baud$flow" select "$slot" || {
mcu_loge "request 'select slot' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
mcu_logi "active firmware slot changed to: '$slot'"
}
mcu_fwfile_sha() {
local path="$1"
local value
[ -f "$path" ] || return 1
value="$(umcumgr -s hash "$path" | grep "hash=" | cut -d '=' -f 2)"
[ -n "$value" ] || return 1
echo "$value"
}
mcu_fw_upload() {
local board="$1"
local slot="$2"
local fw_name="$3"
local uart="$4"
local baud="$5"
local flow="$6"
local fw_path
if [ "$flow" = "1" ]; then
flow=" -f"
else
flow=""
fi
[ -n "$baud" ] || baud="115200"
fw_path="${MCU_FW_DIR}/${board}/${fw_name}/slot${slot}.bin"
umcumgr -q info "$fw_path" > /dev/null 2>&1 || {
mcu_loge "invalid or missing firmware file: '$fw_path'"
return 1
}
mcu_logi "uploading '$fw_name' to slot: '$slot'..."
# Upload fw to selected slot (TODO: slots numbering Zephyr vs. MCUboot)
[ "$slot" = "1" ] && slot="2"
umcumgr -q -n "$slot" -d "$uart" -b "$baud$flow" upload "$fw_path" || {
mcu_loge "request 'upload' failed (uart='$uart', baud='$baud', flow='$flow')"
return 1
}
mcu_logi "firmware uploaded!"
}
mcu_enable_pin_set() {
local gpio="$1"
local gpio_value="$2"
mcu_logd "setting MCU enable_pin '$(basename "$gpio")' to '$gpio_value'"
echo "$gpio_value" > "${gpio}/value" 2>/dev/null
}
mcu_sn_check_and_update() {
local sn="$1"
local uart="$2"
local baud="$3"
local flow="$4"
local sn_dev
# Fetch sysinfo
mcu_fetch_sysinfo "$uart" "$baud" "$flow" || return 1
sn_dev="$(mcu_get "serial_num")"
[ -n "$sn_dev" ] || return 1
[ -n "$sn_dev" ] && {
if [ -z "$sn" ]; then
[ -d /etc/config-shadow ] && {
uci -c /etc/config-shadow -q set mcu.${SECT}.sn="$sn_dev"
uci -c /etc/config-shadow -q commit mcu
}
uci -q set mcu.${SECT}.sn="$sn_dev"
uci -q commit mcu
else
[ "$sn" != "$sn_dev" ] && {
mcu_loge "MCU S/N mismatch ('$sn_dev' != '$sn')!"
return 1
}
fi
}
return 0
}
# Returns:
# 0 if MCU was requested to boot firmware
# 1 on error
# 2 if MCU was requested to reset
mcu_fw_check_and_update() {
local uart="$1"
local baud="$2"
local flow="$3"
local active_slot
local fw_slots
local slot0_fw
local slot0_sha
local slot1_fw
local slot1_sha
local firmware
local fw0_sha
local fw1_sha
local board
local soft_ver
config_get firmware "$SECT" firmware
[ -n "$firmware" ] || mcu_logw "option 'firmware' unset"
# Fetch sysinfo and firmware images list
mcu_fetch_sysinfo "$uart" "$baud" "$flow" || return 1
mcu_fetch_fwlist "$uart" "$baud" "$flow" || return 1
# MCU board name and software version
board="$(mcu_get "board")"
[ $? -eq 0 ] || return 1
soft_ver="$(mcu_get "soft_ver")"
[ $? -eq 0 ] || return 1
# Number of firmware slots and active slot
fw_slots="$(mcu_get "slots_num")"
[ $? -eq 0 ] || return 1
[ -n "$fw_slots" ] || fw_slots="1"
[ "$fw_slots" = "2" ] && {
active_slot="$(mcu_get "active_slot")"
[ $? -eq 0 ] || return 1
}
[ -n "$active_slot" ] || active_slot="0"
# Firmware available?
[ -n "$firmware" ] && {
if [ "$fw_slots" = "2" ]; then
[ -f "${MCU_FW_DIR}/${board}/${firmware}/slot0.bin" -a \
-f "${MCU_FW_DIR}/${board}/${firmware}/slot1.bin" ] || {
mcu_loge "firmware '$firmware' doesn't exist"
return 1
}
fw1_sha="$(mcu_fwfile_sha "${MCU_FW_DIR}/${board}/${firmware}/slot1.bin")"
else
[ -f "${MCU_FW_DIR}/${board}/${firmware}/slot0.bin" ] || {
mcu_loge "firmware '$firmware' doesn't exist"
return 1
}
fi
fw0_sha="$(mcu_fwfile_sha "${MCU_FW_DIR}/${board}/${firmware}/slot0.bin")"
}
slot0_fw="$(mcu_get "fwname" "0")"
[ $? -eq 0 ] || return 1
[ -n "$slot0_fw" ] && {
slot0_sha="$(mcu_get "fwsha" "0")"
[ $? -eq 0 ] || return 1
}
[ "$fw_slots" = "2" ] && {
slot1_fw="$(mcu_get "fwname" "1")"
[ $? -eq 0 ] || return 1
[ -n "$slot1_fw" ] && {
slot1_sha="$(mcu_get "fwsha" "1")"
[ $? -eq 0 ] || return 1
}
}
# No target firmware provided, check what's on device and update config
[ -n "$firmware" ] || {
firmware="$slot0_fw"
[ "$active_slot" = "1" ] && firmware="$slot1_fw"
[ -n "$firmware" ] && {
[ -d /etc/config-shadow ] && {
uci -c /etc/config-shadow -q set mcu.${SECT}.firmware="$firmware"
uci -c /etc/config-shadow -q commit mcu
}
uci -q set mcu.${SECT}.firmware="$firmware"
uci -q commit mcu
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 0
}
return 1
}
# Do we have target firmware installed in the first slot?
[ "$firmware" = "$slot0_fw" -a "$slot0_sha" = "$fw0_sha" ] && {
mcu_logi "found matching firmware installed in slot '0'"
if [ "$fw_slots" = "2" -a "$active_slot" != "0" ]; then
mcu_sel_slot "0" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 2
else
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
fi
return 0
}
mcu_logi "no matching firmware found in slot '0'"
# Upload firmware and reset on single-slot device
[ "$fw_slots" = "1" ] && {
mcu_fw_upload "$board" "0" "$firmware" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 2
}
# Do we have target firmware installed in the second slot?
[ "$firmware" = "$slot1_fw" -a "$slot1_sha" = "$fw1_sha" ] && {
mcu_logi "found matching firmware installed in slot '1'"
if [ "$active_slot" != "1" ]; then
mcu_sel_slot "1" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 2
else
mcu_req "boot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
fi
return 0
}
mcu_logi "no matching firmware found in slot '1'"
# Upload and boot firmware on multi-slot device
# Always use inactive slot
if [ "$active_slot" = "0" ]; then
active_slot="1"
else
active_slot="0"
fi
mcu_fw_upload "$board" "$active_slot" "$firmware" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
mcu_sel_slot "$active_slot" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
# Changing active slots requires MCU reset at the moment
mcu_req "reset" "$uart" "$baud" "$flow"
[ $? -ne 0 ] && return 1
return 2
}
mcu_add_uci_config() {
local name="$1"
local interface="$2"
local bootloader="$3"
local firmware="$4"
local enable_pin="$5"
local uart_path="$6"
local uart_baud="$7"
local uart_flow="$8"
uci -q set mcu.${name}="mcu"
uci -q set mcu.${name}.interface="$interface"
uci -q set mcu.${name}.bootloader="$bootloader"
uci -q set mcu.${name}.firmware="$firmware"
[ -n "$enable_pin" ] && uci -q set mcu.${name}.enable_pin="$enable_pin"
[ -n "$uart_path" ] && uci -q set mcu.${name}.uart_path="$uart_path"
[ -n "$uart_baud" ] && uci -q set mcu.${name}.uart_baud="$uart_baud"
[ "$uart_flow" = "1" ] && uci -q set mcu.${name}.uart_flow="1"
uci -q set mcu.${name}.disabled="0"
uci -q commit mcu
}

View File

@@ -1,25 +0,0 @@
[ -e /etc/config/mcu ] && exit 0
touch /etc/config/mcu
. /lib/functions.sh
. /lib/functions/mcu.sh
board=$(board_name)
case "$board" in
cig,wf196)
mcu_add_uci_config "nrf52833_uart" "uart" "mcuboot" \
"zephyr-v3.3.x__hci_uart" \
"mcu-enable" "/dev/ttyMSM1" "115200"
;;
edgecore,eap102|\
edgecore,oap102|\
edgecore,oap103)
mcu_add_uci_config "nrf52840_usb" "usb" "mcuboot" \
"zephyr-v3.3.x__hci_usb" \
"mcu-enable"
;;
esac
exit 0

View File

@@ -1,47 +0,0 @@
#
# Copyright (C) 2023 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=umcumgr
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://gitlab.com/pepe2k/umcumgr
PKG_SOURCE_DATE:=2024-02-02
PKG_SOURCE_VERSION:=ed34b2816f2b65ee0687944a214fdf6ffd94b85f
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=
PKG_MAINTAINER:=Piotr Dymacz <pepe2k@gmail.com>
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
CMAKE_INSTALL:=1
CMAKE_OPTIONS += -DTI_SERIAL_BL_SUPPORT=ON
CMAKE_OPTIONS += -DTI_SERIAL_BL_DUMPCMD=ON
CMAKE_OPTIONS += -DCONFIRM_TEST_SUPPORT=OFF
define Package/umcumgr
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=+libubox
TITLE:=User space tool for MCUmgr SMP based management
endef
define Package/umcumgr/description
Simple user space tool for MCU management over MCUmgr SMP protocol
and Texas Instruments CC13x2/CC26x2 ROM serial bootloader
endef
define Package/umcumgr/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/umcumgr $(1)/usr/bin/
endef
$(eval $(call BuildPackage,umcumgr))

Some files were not shown because too many files have changed in this diff Show More