Skip to content

This project can Nuvoton ISP Firmware update on Android with USB HID(Android side)-UART(MCU side) communication.

Notifications You must be signed in to change notification settings

Super-Thomas/Using_Nuvoton_ISP_on_the_Android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using_Nuvoton_ISP_on_the_Android

Intro

You can ISP firmware update to Nuvoton MCU on the Android with this project. I will use USB HID in Android Device for this. USB HID protocol is follow to “NuMicro ISP Programming Tool version 4.03 for Windows OS” provided by Nuvoton. So if you programed ISP firmware for USB HID in Nuvoton SDK to your Nuvoton parts, your Nuvoton parts can connect to Android app in this project with USB HID.
If you use Bridge firmware in this project, you can ISP firmware update to MCU not support USB. In fact, Bridge firmware is not required if you will use USB CDC in Android. But if you want to implement another function in Bridge firmware, it would be better choice. If you looking for simple version of Nuvoton ISP program on Windows OS, Please refer Nuvoton_ISP_Lite_for_Windows.

Development environment

For Android app

N Name Description Note
1 Android OS Version 6.0 - Marshmallow (API level 23)
2 Android Studio Version Bumblebee 2021.1.1 Patch2 IDE

For Bridge firmware

N Name Description Note
1 ARM MDK Keil uVision Version 5.34.0.0 IDE
2 Nano100B SDK Version 2021.9.23
3 Nu-LB-NANO130 REV 1.2 Hardware

For ISP Test

N Name Description Note
1 UDOO Dual with Android 6.0 - Marshmallow Hardware
2 Nu-LB-NANO130 REV 1.2, with Bridge firmware Hardware
3 NuTiny-SDK-Mini54FDE V1.0, with ISP_UART firmware in LDROM Hardware

System Overview(used Bridge firmware)

image
Your Android device and Nu-LB-NANO130(CON2) are connected by USB. Nu-LB-NANO130(PD0, PD1) and NuTiny-SDK-Mini54FDE(P12, P13) are connected by UART.

How to ISP Firmware update on the Android(used Bridge firmware)

  1. Please select that which item will try to connect USB you want in USB list. For your information, Vendor ID is 1046 and Product ID is 20512 of USB information for Bridge firmware. image

  2. Please approve about USB permission of app. image

  3. Please press the connect button. Then Bridge firmware will try to connect target board. After then target board must be reset. Then target board will be boot up from LDROM, it can be processing packet for ISP connect. image

  4. If connect is successful, you can see the text of "USB Connected" and parts number. Please refer that if there no have your parts information in android app, it will be failed about connection. As you know, most embedded device maybe not enough resource. So I didn’t do add to this which parts information of all from Nuvoton. If you want add to your parts information, Please refer “How to add parts information in the Android app” in this document. image

  5. Please select binary file for APROM of target board after press APROM button. And then please press the program button. Then file you selected will be program to APROM of target board. image
    image
    image

  6. If you get alert message about successful, you can confirm that whether target board is work well after reset the target board. image
    image

Software Description

image “NvtISPFragment.java” will handling for GUI and ISP. It will be send packets to Bridge firmware by the user's action(Like the click button). There have thread for ISP also. This thread will handling packets received from Bridge firmware. Connection and communication for USB HID is via "HidBridge.java". You can send packet via USB using WriteData function. There have thread for handling packets received from USB.
Bridge firmware will handling packets of USB and UART. It will send packets received from Android app to target board via UART. Also it will send packets received from target board to Android app via USB.

How to add parts information in the Android app

You can see "NvtChipInfo.java" in android app source tree. You can add parts information you want in this file. MAX_DEVICE_COUNT value is number of supported devices. Parts information will add to SupportDevicesList function. If you added new part information, you need to increase MAX_DEVICE_COUNT value. Parts information is stored as array. This array will use for searching parts ID by GetChipStaticInfo function later. Values for parts information is same as ISPTool provided by Nuvoton. You can refer link below.
https://github.com/OpenNuvoton/ISPTool/blob/master/NuvoISP/DataBase/PartNumID.cpp

Packet Description

Packet size is 64 Byte. There have 4 Byte of command list and 4 Byte of command index. You can ignore command index in the packet.
image

Please refer table below for command list.

Command Value(Hex/4 Byte) Description Note
CMD_UPDATE_APROM 0x000000A0 Update data to the internal flash of target board.
CMD_CONNECT 0x000000AE Try connect to target board.
CMD_GET_DEVICEID 0x000000B1 Request device ID to target board.
CMD_UPDATE_SPIFLASH 0x000000D1 Update data to the external flash of target board.

CMD_CONNECT

Try connect to target board. You must send this packet to target board every few millisecond during reset for target board. Target board must be received this packet when boot-up.
Host -> Target board
image

If target board received this packet from Host, Target board will send packet same as CMD_CONNECT packet to Host.
Target board -> Host
image

CMD_GET_DEVICEID

Request device ID to target board.
Host -> Target board
image

If target board received this packet from Host, Target board will send packet include device ID to Host. You can refer to device ID for each device here.
Target board -> Host
image

CMD_UPDATE_APROM

Update data to the internal flash of target board. There have two kind of packet. If you send CMD_UPDATE_APROM packet to target board for first time, You must send packet include Start address and Total length like as picture below.
Host -> Target board
image
Start Address: This is start address that where you need write buffer data.
Total Length: This is total length for buffer you needs write to flash.

You can send following packet after sent packet for first time.
Host -> Target board
image

If target board received this packet from Host, Target board will send packet include CRC for received packet to Host.
Target board -> Host
image

CMD_UPDATE_SPIFLASH

Update data to the external flash of target board.
image
Start Address: This is start address that where you need write buffer data.
Write Length: Write buffer size.

If target board received this packet from Host, Target board will send packet include CRC for received packet to Host.
Target board -> Host
image

Thanks to

https://gist.github.com/ns50254/e5a265990eb8b145d04d
https://github.com/OpenNuvoton/ISPTool
https://github.com/OpenNuvoton/Nano100B_BSP/tree/master/SampleCode/StdDriver/USBD_HID_Transfer
https://github.com/OpenNuvoton/Nano100B_BSP/tree/master/SampleCode/StdDriver/UART_TxRx_Function
https://github.com/OpenNuvoton/Mini51BSP/tree/master/SampleCode/ISP/ISP_UART