949 views|6 replies

1w

Posts

25

Resources
The OP
 

UF2 bootloader for CH32V2xx / CH32V3xx [Copy link]

UF2 bootloader for WCH RISC-V microcontrollers. This allows updating the program by dragging the file to a virtual USB mass storage device, no special software is required.

Instructions

  • Triggered by double-clicking the reset button within 0.5 seconds
  • Need to use R16BKP_DATAR10
    • Write 0x4170 ('Ap') to boot immediately into the application without delay
    • Write 0x624c ('bL') to unconditionally enter the bootloader
  • Suitable for 4096 bytes
  • Tested and built with MounRiver GCC V1.91
    • Improve code size by using "XW" instructions that are not upstream
  • Only USBD peripherals are supported (i.e. no USBFS support)
    • USBD and USBFS are completely different. The QFN28 package (the largest number on LCSC) only combines USBD
    • Note that if using the official devkit's USBD you will need a USB aa cable
  • Internal 8 MHz oscillator (although there are stability issues)
    • The tolerance of the HSI oscillator (-1.0% to +1.6%) is well outside the specified range for USB full speed ($\pm$0.25%), but it seems to work in practice
    • The ISP ROM bootloader also does this
  • Should work for most CH32V2xx and CH32V3xx families with appropriate changes to the hard coded constants.
  • Allows downloading to flash and SRAM with the "non-primary flash" flag (this is how the RP2040 bootrom works)
    • The Flash download address must be 08xxxxxx (not starting from 0)
    • The SRAM download address must be 20xxxxxx
    • The entire size of the SRAM can be used because the USBD contains a buffer memory independent of the main SRAM
  • Automatic restart after download is complete, but this only works if the download is small enough. Larger downloads will still update but will not trigger an automatic restart and will require a manual restart.

链接已隐藏,如需查看请登录或者注册

This post is from DIY/Open Source Hardware

Latest reply

I also used uf2 to update the firmware of my GD32F303, which is more convenient and can solve the USB flash drive update problem without FATFS.   Details Published on 2024-5-28 12:27
 

7422

Posts

2

Resources
2
 

What is UF2?

This post is from DIY/Open Source Hardware

Comments

The bootloader format released by Microsoft uses a disk to update the program.  Details Published on 2024-5-17 20:00
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

1w

Posts

25

Resources
3
 

The bootloader format released by Microsoft uses a disk to update the program.

This post is from DIY/Open Source Hardware

Comments

Disk mode? Is it similar to mbr?  Details Published on 2024-5-27 19:09
 
 
 

6818

Posts

11

Resources
4
 

This is very cool to use and solves a big file problem.

This post is from DIY/Open Source Hardware
 
 
 

7422

Posts

2

Resources
5
 
dcexpert posted on 2024-5-17 20:00 The bootloader format released by Microsoft uses the disk method to update the program.

Disk mode? Is it similar to mbr?

This post is from DIY/Open Source Hardware
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

1127

Posts

17

Resources
6
 

I also used uf2 to update the firmware of my GD32F303, which is more convenient and can solve the USB flash drive update problem without FATFS.

This post is from DIY/Open Source Hardware
 
 
 

1w

Posts

25

Resources
7
 
fxyc87 posted on 2024-5-28 12:27 I also used uf2 to update the firmware of my GD32F303, which is more convenient and can solve the USB flash drive update problem without FATFS.

This post is from DIY/Open Source Hardware
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list