简体   繁体   English

从Android进行STM32设备固件升级(DFU / DfuSe)

[英]STM32 Device Firmware Upgrade (DFU/DfuSe) from Android

I have an STM32F4 microcontroller connected to an Android (4.4) USB Host port. 我有一个连接到Android(4.4)USB主机端口的STM32F4微控制器。 I would like to do a firmware upgrade of the microcontroller from the Android device. 我想从Android设备对微控制器进行固件升级。

===================                           ===================
|   Android 4.4   | <=======================> |   STM32F405xx   |
|     Device      | USB Host      USB Device  | Microcontroller |
===================                           ===================

Traditionally, STM32 microcontrollers can have their firmware upgraded using the PC tool called DfuSe Utility provided by ST. 传统上, STM32微控制器可以使用ST提供的称为DfuSe Utility的PC工具升级固件。 But I need to do this from an Android device instead. 但是我需要从Android设备执行此操作。 The source for their tools are provided. 提供了其工具的来源。

Questions: 问题:

  1. Can the firmware for the microcontroller be upgraded using the standard USB Host libraries from Android in Java ? 可以使用Java来自Android的标准USB主机库来升级微控制器的固件吗?
  2. Or does this need to be done using the NDK , and port the DfuSe source? 还是需要使用NDK并移植DfuSe源? If so, which libraries should be used to access USB from the NDK ? 如果是这样,应该使用哪些库从NDK访问USB?

Which direction should be taken and how can this be done? 应该采取哪个方向以及如何做到?

We ended up creating our own solution to program a STM32 microcontroller directly from Android over USB using DFU without using the NDK. 我们最终创建了自己的解决方案,无需使用NDK就可以直接使用DFU通过USB通过Android对STM32微控制器进行编程。 We open sourced the project here: 我们在这里开源项目:

https://github.com/UmbrelaSmart/android-stm32-dfu-programmer https://github.com/UmbrelaSmart/android-stm32-dfu-programmer

In my project I just program the STM32 as a virtual com port device and define a group of simple communication protocol to erase/write the internal flash of STM32. 在我的项目中,我只是将STM32编程为虚拟COM设备,并定义了一组简单的通信协议来擦除/写入STM32的内部闪存。 I think you can do the same for the Andriod but I don't know if there is existing driver for a virtual com port in android. 我认为您可以对Andriod执行相同的操作,但是我不知道android中是否存在用于虚拟com端口的驱动程序。

But no matter how, once you can transmit a byte to and from STM32, you can let it program itself. 但是无论如何,一旦可以在STM32之间传输一个字节,就可以让它自己编程。 The basic function of a bootloader is really simple which is just receive data and write them where they should be. 引导加载程序的基本功能非常简单,它只是接收数据并将它们写入应有的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM