将TypeC的adb切换到USB3.0口

rk3399调试usb支持u盘鼠标等 调试支持usb功能 阅读详情
AI摘要

本文介绍在Rockchip RK3399平台上,如何通过修改设备树和内核配置,将ADB调试接口从Type-C切换至USB3.0端口。此方法适用于Android 7.1版本,涉及设备树修改、内核编译及系统设置。

前言

目前大多数Android的嵌入式系统都会使用TypeC做为adb的调试口,这样很方便。但是在有的时候,迫不得已必须将adb功能切换到USB3.0口,但由于当前的内核USB框架只能支持一个USB口作为Peripheral
功能,所以RK3399 SDK默认配置Type-C0作为OTG mode 支持USB Peripheral功能,而Type-C1只支持Hostmode。

注意: 下面介绍的方法只在rk3399的Industry的7.1版本上实现成功并测试过,其他版本仅做参考,但也大同小异。

Kernel: v4.4.126
Device: rk3399
Platform Version: Android 7.1

硬件

首先,参考原理图如下:

1

Device Tree

RK提供的dts中默认的rk3399.dtsi,默认

 usbdrd3_0: usb@fe800000 {
  	...
    usbdrd_dwc3_0: dwc3@fe800000 {
        compatible = "snps,dwc3";
        dr_mode = "otg";
    };
...
};
usbdrd3_1: usb@fe900000 {
    ...
    usbdrd_dwc3_1: dwc3@fe900000 {
        compatible = "snps,dwc3";
        dr_mode = "host";
    };
...
};

我们需要在自己的dts中修改usbdrd_dwc3_1的dr_mode模式为otg,将usbdrd_dwc3_0的模式修改为host

&usbdrd_dwc3_0 {
	status = "okay";
	dr_mode = "host";
};

&usbdrd_dwc3_1 {
	status = "okay";
	dr_mode = "otg";
};

Drivers

  1. kernel/include/linux/phy/phy.h

     diff --git a/kernel/include/linux/phy/phy.h b/kernel/include/linux/phy/phy.h
     index a3965c3..c0daa66 100644
     --- a/kernel/include/linux/phy/phy.h
     +++ b/kernel/include/linux/phy/phy.h
     @@ -36,6 +36,7 @@ enum phy_mode {
       * @power_on: powering on the phy
       * @power_off: powering off the phy
       * @set_mode: set the mode of the phy
     + * @set_vbusdet: usb disconnect of the phy
       * @reset: resetting the phy
       * @cp_test: prepare for the phy compliance test
       * @owner: the module owner containing the ops
     @@ -46,6 +47,7 @@ struct phy_ops {
     	    int     (*power_on)(struct phy *phy);
     		int     (*power_off)(struct phy *phy);
     		int     (*set_mode)(struct phy *phy, enum phy_mode mode);
     +    int (*set_vbusdet)(struct phy *phy, bool level);
     		int     (*reset)(struct phy *phy);
     		int     (*cp_test)(struct phy *phy);
     		struct module *owner;
     @@ -133,6 +135,7 @@ int phy_exit(struct phy *phy);
      int phy_power_on(struct phy *phy);
      int phy_power_off(struct phy *phy);
      int phy_set_mode(struct phy *phy, enum phy_mode mode);
     +int phy_set_vbusdet(struct phy *phy, bool level);
      int phy_reset(struct phy *phy);
      int phy_cp_test(struct phy *phy);
      static inline int phy_get_bus_width(struct phy *p
设备树总结-基于rk3588 关于设备树的一些总结 阅读详情

相关推荐

[RK3399]解决type-c无法连接adb

Platform: ROCKCHIP Chip: RK3399 OS: Android7.1.2 Kernel: 4.4.126 现象 正常的板子接入type-c的打印如下 手上调试的板子接入type-c的打印如下 RK3399的type-c原理 RK3399 SoC 内部 4 个 USB 控制器与 USB PHY 的连接如下图 。 DP 是指 Display Port 控制器,DP 与 USB 3.0 共用 Type-C PHY。一个完整的type-C 功能,是由 Type-C USB 3.0 PHY

但行前路 无问西东 5465

【RK3399 android10 W3S 二合一 typeC OTG切换HOST和DEVICE 】

文章目录【RK3399 android10 W3S 二合一 typeC OTG切换HOST和DEVICE 】 【RK3399 android10 W3S 二合一 typeC OTG切换HOST和DEVICE 】

A08118139的博客 1942

USB typec to adb

在移植dwc3驱动时,实现adb功能,记录该功能的实现以及相关驱动的流程

changcheng00的博客 2008

RK3399 Android10 TypeC OTG模式切换:从硬件缺陷到软件驱动的解决方案

本文深入探讨了RK3399 Android10开发板TypeC OTG模式切换的硬件缺陷及软件驱动解决方案。通过分析TypeC接口电路设计问题,提出绕过TypeC协议栈直接操作USB2.0链路的创新方法,实现100% U盘识别率和稳定模式切换,显著提升设备兼容性和工作效率。

weixin_30352645的博客 467

Type-C线竟能调试车机?揭秘ADB连接中的接口冷知识

本文深入探讨了车载测试中ADB连接的核心难点,揭示了Type-C线缆无法调试车机的根本原因。文章从硬件接口协议、车机工程模式开启、授权问题破解及线材选购等多维度,提供了针对不同品牌车型的ADB连接实战解决方案与排错指南,帮助测试工程师高效完成调试工作。

k8s6orchestrator的博客 898

RK平台USB调试全链路诊断:从硬件接口到ADB识别的深度解析

本文深入解析RK平台USB调试全链路问题,从硬件接口到ADB识别的完整排查流程。针对RK开发板连接电脑时常见的ADB识别失败问题,提供从Type-C线材选择、USB接口检查到驱动配置、内核调试的全面解决方案,帮助开发者快速定位并解决USB调试难题。

weixin_29184075的博客 159

RK3399安卓10 TypeC OTG模式切换实战:手把手教你解决U盘识别问题

本文针对RK3399开发板在Android 10系统下,因Type-C接口CC引脚缺失导致OTG模式无法自动切换、U盘无法识别的问题,提供了从硬件原理分析到内核驱动修改的完整实战解决方案。文章深入剖析了FUSB302芯片角色检测机制,并最终通过修改USB PHY驱动,实现手动强制切换HOST/DEVICE模式,成功解决了U盘识别难题。

weixin_29165465的博客 276

RK3399 Android10 TypeC OTG模式手动切换方案解析与实现

本文针对RK3399 Android10平台Type-C接口OTG功能失效问题,提供了深度解析与手动切换实现方案。通过分析硬件原理图缺陷(FUSB302 CC引脚悬空),并深入RK3399 USB架构,最终提出绕过自动检测、直接强制切换USB控制器角色的软件方案。文章详细阐述了通过修改设备树、操作USB Gadget与Host控制器驱动,并封装为系统服务,实现稳定可靠的HOST/DEVICE模式手动切换,解决了因硬件设计导致的OTG功能不可用问题。

prometheus9mon的博客 257

Android10 TypeC外设识别失败?手把手教你排查RK3399 OTG功能问题

本文详细解析了RK3399开发板在Android10系统下TypeC接口OTG功能失效的排查与解决方法。从硬件原理图检查到Linux内核驱动调试,再到Android系统层配置优化,提供了一套完整的故障排查指南。特别针对TypeC外设识别失败问题,给出了硬件修改和软件适配两种解决方案,并分享了实用的调试命令集锦。

weixin_30352645的博客 459

Jetson Xavier NX USB OTG功能实现:手把手教程

详解Jetson Xavier NX如何启用和配置USB OTG功能,实现设备模式切换与数据传输,适用于嵌入式开发场景,提升jetson xavier nx的扩展能力与应用灵活性。

weixin_42418754的博客 1019

TypeC转USB识别不了U盘?RK3399的fusb302驱动修改实战记录

本文记录了在RK3399平台上,因Type-C接口缺少CC引脚导致无法识别U盘的问题分析与解决过程。通过深入剖析FUSB302驱动状态机,提供了强制切换USB HOST模式的实战方案,包括修改内核驱动、创建sysfs控制接口以及底层USB控制器配置,为嵌入式开发中类似硬件限制问题提供了有效解决路径。

weixin_29188997的博客 112

Android14 USB子系统动态配置机制解析:从传统模式到Configfs的演进

本文深入解析Android14 USB子系统的动态配置机制,重点介绍从传统模式到Configfs架构的演进。通过对比分析传统硬编码方式与Configfs的动态配置优势,揭示Android14在USB功能切换灵活性、开发效率等方面的重大改进,并分享高通平台实现差异及Type-C角色控制等实战经验。

weixin_42632434的博客 443

深入浅出:高通USB驱动与充电协议的那些事儿(含Type-C接口详解)

本文深入解析高通USB驱动与充电协议的技术细节,涵盖Type-C接口设计、充电协议栈层级、PMIC电流管理及眼图调试实战。特别探讨USB Type-C的24针物理连接和CC引脚动态角色切换,以及QC4.0和PD3.0协议的协商机制,为开发者提供全面的技术参考和实践指南。

weixin_29165725的博客 426

RK3588平台开发系列讲解(硬件篇-功能外设2)

RK3588 芯片内置两个USB3.0 OTG控制器(内嵌2个USB2.0 OTG,下图绿色处),1个USB3.0 HOST 控制器,2个USB2.0 HOST控制器。这些控制器与PHY的内部复用图如下:USB3.0 OTG0 控制器支持SS/HS/FS/LS, 内嵌的USB2.0(HS/FS/LS)信号采用USB2.0 OTG PHY, 信号名见下图的红色方框内;RK3588目前仅此接口支持做Fireware的Download,应用中请务必要预留出。

whm128的博客 2508

rk3568 适配USB

USB(通用串行总线)是一种常见的电脑外部设备连接标准。它是一种用于连接计算机和外部设备的通信接口。USB接口是一种热插拔技术,能够在计算机运行时插拔设备而无需重启系统。

weixin_35723192的博客 1876

PADS VX2.7学习记录06-PADS Router软件功能操作

PADS VX2.7学习记录06-PADS Router软件功能操作

qq_31444421的博客 7860

Frida实战:高效dump Android内存中的so文件与修复技巧

本文详细介绍了使用Frida工具dump Android内存中已解密so文件的实战技巧。针对加固应用静态分析失效的痛点,文章提供了从环境搭建、使用frida_dump脚本自动化抓取内存数据,到利用SoFixer工具修复ELF文件结构的完整流程,帮助逆向分析人员高效获取可分析的so文件。

tt34567的博客 527

博途 V15.1安装步骤

温馨提醒:安装此软件电脑配置至少应满足以下要求 处理器 CoreTM i5-3320M 3.3 GHz 或相当 内存 至少8G 硬盘 300 GB SSD 显示器 15.6' 宽屏显示 (1920 x 1080) 1.双击打开【Siemens v15.1】文件夹。 2.鼠标右击【STEP 7 BasicProfess...

谢谢关注“小鱼教你模数电”,各平台同号 9万+

别再死记硬背了!用‘小乌龟’实战图解ROS1核心指令(rosnode/rostopic/rosparam保姆级手册)

本文通过经典的turtlesim乌龟仿真器,以可视化实战方式讲解ROS1核心指令(rosnode/rostopic/rosparam),帮助初学者摆脱死记硬背,在操控乌龟的过程中轻松掌握节点管理、话题通信和参数设置等ROS1核心概念。

weixin_28731223的博客 370

语义通信实战:跳过“比特”保“语义”,手把手构建轻量级图像压缩重建网络(基于PyTorch)

本文详细介绍了基于PyTorch的轻量级语义通信系统LICRnet的实现,专注于图像压缩重建中的语义信息保留。通过深度可分离卷积、可变窗口多尺度注意力等创新技术,显著降低计算量并提升性能,特别适用于无人机巡检、远程医疗等物联网场景。文章包含完整的代码实现、训练策略及部署优化方案。

weixin_27697385的博客 220

本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印

本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印

ProceduralMan的博客 7410

FineReport实战-- 国内外各地区销售数据分析 多个图表联动

进行国内外各地区业务员销售数据分析是一项复杂但极具价值的任务,它可以帮助企业了解不同市场的表现,并据此调整销售策略以提高整体绩效。实现功能:同一个报表里面多个图表联动问题。

Davina_yu的博客 1198

读懂 403 Forbidden, the request has been blocked by UCON.:它不是浏览器渲染问题,而是后端安全闸门在拦截

摘要 403 Forbidden 错误表明服务器理解请求但拒绝执行,通常与权限或访问控制有关。当错误信息显示 "blocked by UCON" 时,说明请求被 SAP 体系中的统一连接管控框架拦截。UCON 采用白名单机制限制外部调用,通过记录、评估、强制三阶段流程实施管控。常见触发场景包括 HTTP 服务与通信场景配置不一致、白名单未更新等。排查时应通过 DevTools 确认服务器响应,使用 curl 排除浏览器干扰,并比较不同环境的行为差异。解决方案通常涉及调整配置传输顺序或更新

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 239

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

上一篇: frameworks中增加自定义服务使其也成为系统服务
下一篇: uboot命令行从U盘升级kernel
lostnx
博客等级 码龄10年 45粉丝 43原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值