[串口烧写] 给C2000 DSP写了个串口下载工具serial_flash_programmer

[复制链接]
170|0
imdx 发表于 2025-10-21 08:53 | 显示全部楼层 |阅读模式
一直以来我都在找一张小巧的TI DSP开发板用来测试代码,只要内核是C28x就可以,性能和闪存容量都不重要,我之前用树莓派外形做的开发板PI035感觉还是大了点,一两张没什么问题,十几张就要开始考虑收纳问题,最好是BluePill那么大,DIP-40接口,引出40P的双排2.54排针,可以直接调试使用,也可以插到底板上使用。找了一圈没有合适的,那就自己做吧,芯片选择F28027,这是Piccolo系列最小的芯片了,F28027有个38PIN的TSSOP封装,不过因为市面上用得少,并不容易买到,价格也不好,还是用LQFP-48封装,这是经典BluePill使用的STM32F103C8T6的封装,两颗芯片无论存储容量还是主频都差不多。
由于体积限制,传统的14PIN JTAG接口肯定不能用了,一个接口都快赶上整个板子尺寸了,平时我都是用串口下载固件,JTAG接口就不引出来了,偶尔需要调试的话可以直接用杜邦线连接JTAG接口,最终做完是这个样子的:
外观尺寸和普通的BluePill完全一致,40P双排针上的电源接口也完全一致,烧录固件通过单独引出的SCIA进行。先按住TDO按键,再按一下XRS按键复位,就可以进入28027新版内置的Bootloader,使用C2Prog通过串口进行固件烧录。平时开发使用C2Prog完全够了,然而生产烧录的时候,我喜欢用脚本调用命令行工具来烧录,ARM和RISC-V系列芯片都有自己的命令行烧录工具,而C2000并没有一个广泛使用的命令行烧录工具,TI提供的固件包C2000Ware里面有一个命令行烧录工具serial_flash_programmer,我简单试了下,软件完成度太低了,它使用了一种不太常见的txt和bin格式固件,每次烧录要转换固件文件,非常麻烦,基本没有可用性。好在TI提供了serial_flash_programmer的源代码,既然不好用,那就手搓一个更好用的版本,于是我的serial_flash_programmer就诞生了。
主要特性如下:
  • 使用常见hex文件烧录
  • 无需指定kernel文件
  • 支持指定CSM密码烧录
  • 支持擦除掩码
目前在F2802x、F2803x、F2806x、F2833x系列芯片都已经测试通过,这些是我常用的芯片,测试比较方便,其它型号暂未支持。
烧录终端工具推荐使用powershell,没有参数的情况下serial_flash_programmer会打印帮助信息:
serial_flash_programmer
C2000 Serial Firmware Upgrader v25.7.22
Copyright (c) 2025 Texas Instruments & ECHO Studio.  All rights reserved.
This application may be used to download images to a Texas Instruments
C2000 microcontroller in the SCI boot mode.

Supported parameters are:

-p COM<num>   - Set the COM port to be used for communications.
-d <device>   - The name of the device to load to:
                f2802x, f2803x, f2805x, f2806x, f2833x, f2837xD, f2837xS, f2807x,
                f28004x, f2838x, f28002x, f28003x, f280013x, f280015x, f28p65x, or f28p55x.
-f <file>     - The file name for download use.
                This file can be intel hex or TI sci8 binary boot format.
-b <num>      - Set the baud rate for the COM port, default 38400.
-c <hex num>  - Specify the CSM password. Must be eight Uint16 for 128 bits.
-s <hex num>  - Specify the sector mask. bit0 for SECTORA, bit1 for SECTORB...
-h or -?      - Show this help.
-q            - Quiet mode. Disable output to stdout.
-w            - Wait for a key press before exiting.
-v            - Enable verbose output

-p and -d are mandatory parameters.
Application files can be intel hex or TI sci8 binary boot format. These can
be generated using the hex2000 utility. An example of how to do this follows:
hex2000 application.out --romwidth 16 --intel  -o application.hex
hex2000 application.out --sci8 --boot --binary -o application.bin
烧录时最少要3个参数,-p指定串口号,-d指定芯片型号,-f指定烧录的hex文件。一个烧录固件的例子如下:
serial_flash_programmer -p COM3 -d f2802x -f .\XBOOT_28027.hex
C2000 Serial Firmware Upgrader v25.7.22
Copyright (c) 2025 Texas Instruments & ECHO Studio.  All rights reserved.
getting comm state
building comm DCB
adjusting port settings
calling f05_DownloadImage
Kernel AutoBaud Successful!
Downloading f2802x_flash_kernel to device...
--------------------
Kernel Loaded.
Done Waiting for kernel boot...
Attempting autobaud...
Application AutoBaud Successful
Downloading App File .\XBOOT_28027.hex to device...
Checksum passed. EntryAddr=0x003F7FF6
--------------------------------
This is the last record, download successful
Application Load Successful
工具下载链接在github上,只有一个单exe文件,下载解压7z压缩包以后,可以校验md5后再使用。
https://github.com/xjtuecho/BluePill/tree/master/hardware/BluePill027
如果访问github有困难,也可以直接下载附件:


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

123

主题

905

帖子

8

粉丝
快速回复 在线客服 返回列表 返回顶部