DshanMCU-R128s2 烧写固件

编译系统源码后,打包后生成的系统文件称之为固件。固件一般为.img格式。把固件下载到开发板或者产品上的过程称之为 烧写固件 。
烧录模式r128 有两种烧录模式,分别为 usb 烧录与uart烧录。烧录模式以芯片 rst 时 pa1,pa2 引脚高低电平控制。
r128 module 默认配置为 usb 烧录,pa2 已经在模组通过下拉电阻下拉。
pa1pa2模式
1 1 非法模式
1 0 正常启动
0 1 uart 下载
0 0 usb 下载
usb 烧写r128 支持使用 usb 烧写系统。对于 windows 用户可以使用 phoenixsuit 进行烧写。是最常用的烧写工具,通过数据线将pc和开发板连接,把固件烧到开发板上。phoenixsuit 支持分区烧写,适用于开发和小规模生产使用。
phoenixsuit - windows打开phoenixsuit点击浏览,选择固件点击全盘擦除升级
使用 usb 数据线连接 usb otg (usb转串口也可以连接,用于烧录查错)
按住 fel 键,然后点击 reset 键重置开发板
reset 点击后 phoenixsuit 会自动进入烧录模式,开始下载
烧录完成
phoenixsuit 单独分区烧录在开发的时候,会遇到只需要烧录单独分区的情况,例如只修改了 rv 核心的固件,不需要全盘下载。就可以选择单独分区烧录功能。
选择单或多分区下载,phoenixsuit 会解析固件并生成分区表选择需要下载的核心的固件
phoenixsuit - linuxlinux 版本 phoenixsuit 支持的发行版本包括 ubuntu、fedora、redhat 及 centos 等几个常见的发行版本。目前驱动已经可以支持 4.11.0 版本以上内核,建议安装内核版本号大于4.11.0 的 linux 发行版本。
安装 phoenixsuit - linux下载 phoenixsuit 到 linux 中,解压
安装依赖 dkms,对于 ubuntu 可以用 sudo apt install dkms dctrl_tools 来安装!
打开终端,输入 sudo ./phoenixsuit.run 来运行安装程序。
使用 usb 数据线连接 usb otg (usb转串口也可以连接,用于烧录查错)
按住 fel 键,然后点击 reset 键重置开发板使其进入下载模式
安装完成后可以用 lsusb 查看 usb 设备,找到 id 1f3a:efe8,找到即安装完成。
烧录使用命令 sudo ./phoenixsuit rtos_xxx_uart0_16mnor.img 下载烧录 rtos_xxx_uart0_16mnor.img
显示 clos image ok! 时,按住 fel 引脚,点击 reset 键使芯片进入下载模式
开始烧录
烧录完成
虚拟机 linux 烧录如果使用的是虚拟机连接开发板烧录,先运行 sudo ./phoenixsuit rtos_xxx_uart0_16mnor.img 下载烧录 rtos_xxx_uart0_16mnor.img,先进入下载模式。
选择设备-usb,选择 onda 设备连接虚拟机
开始烧录,但是运行到 dev plugout the device path is /dev/aw_efex0 会卡住
此时需要重新到 设备-usb 重新连接 usb 设备,这是因为芯片烧录时需要重置usb,导致usb编号变化,虚拟机不会自动连接。
开始下载
如果长时间没有重新连接 usb 设备,phoenixsuit 会超时自动退出,报错如下
如果刚才长时间没有重新连接,超时后连接上 usb 设备,重新运行sudo ./phoenixsuit rtos_xxx_uart0_16mnor.img 下载命令。会出现 errpr!!!: pnpfesin error! 这是因为烧录启动时的 usb 模式不匹配导致的,之前的操作导致usb进入了 ffff 模式。此时需要按住 fel 引脚,点击 reset 键使芯片进入下载模式重新下载(下载模式会显示 02b3)
phoenixsuit - macos下载解压 phoneixsuit_macos.zip在 mac 电脑中进入终端,将目录切到工具目录下执行命令 chmod 777 ./phoenixsuit 赋予运行权限使用命令 ./phoenixsuit rtos_xxx_uart0_16mnor.img 下载烧录 rtos_xxx_uart0_16mnor.img设备重新到 boot 的时候会自动进行烧写烧写成功,设备重启
usb 烧写的流程r128 系统的烧写流程如下:
片内引导 brom 初始化芯片,识别到 pa1,pa2 脚为 usb 烧录模式,初始化 usb上位机通过 usb 烧写 boot0 到 sram 中,并运行 boot0boot0 初始化 psram,返回完成信号等待上位机下载 boot1(u-boot)上位机收到信号,下载 boot1(u-boot)到 psram 中,并引导运行 boot1(u-boot)boot1(u-boot) 初始化系统资源,初始化内部 spi nor,usb2.0 等资源,等待上位机下载上位机下发固件,进入烧写模式,烧写固件usb 烧录 log[0]fes begin commit:61c5f1c6[2]set pll end[3]board init ok[5]fake dram ok[7]heap: 0x40a0000 size:0xe000[9]lpsram init[11]lspsram init aps64[13]lspsram dqs:0x011b01b0[18]psram chip aps64 init ok!, freq 1920000000[22]init psram controller ok[24]hpsram init[26]dram dqs gate is pd mode.[29]dram boot drive info 001: v2.00[32]dram clk = 800 mhz[34]dram_tpr11 = 0x0 , dram_tpr12 =0x0[38]dram_tpr9 = 0x2222[68]dram simple test ok.[70]dram size =8 mb[82]fes1 doneu-boot 2018.05-g024e8cd (jul 04 2023 - 03:57:33 +0000) allwinner technology[01.080]cpu: allwinner family[01.083]model: sun20iw2[01.086]dram: 8 mib[01.096]relocation offset is: 00799000[01.131]secure enable bit: 0[01.135]cpu=384 mhz,pll6=192 mhz,ahb=192 mhz, apb1=96mhz mbus=4125mhz[01.142]sunxi flash type@0 not support fast burn key[01.146]flash init start[01.149]workmode = 16,storage type = 0try card 0set card number 0get card number 0[01.157][mmc]: mmc driver ver uboot2018:2021-07-19 14:09:00[01.166][mmc]: get sdc_type fail and use default host:tm1.[01.209][mmc]: can't find node mmc0,will add new node[01.214][mmc]: fdt err returned [01.218][mmc]: using default timing para[01.221][mmc]: sunxi sdmmc controller version:0x50310[01.235][mmc]: mmc 0 cmd timeout 100 status 100[01.240][mmc]: smc 0 err, cmd 8, rto[01.243][mmc]: mmc 0 close bus gating and reset[01.248][mmc]: mmc 0 cmd timeout 100 status 100[01.253][mmc]: smc 0 err, cmd 55, rto[01.256][mmc]: mmc 0 close bus gating and reset[01.265][mmc]: mmc 0 cmd timeout 100 status 100[01.269][mmc]: smc 0 err, cmd 1, rto[01.272][mmc]: mmc 0 close bus gating and reset[01.277][mmc]: card did not respond to voltage select![01.282][mmc]: mmc_init: -95, time 56[01.285][mmc]: mmc_init: mmc init fail, err -95mmc init failedtry emmc failspi sunxi_slave- >max_hz:50000000sr3:0x68 -- > 0x68sf: detected w25q128 with flag 0x301 with page size 256 bytes, erase size 4 kib, total 16 mibnot boot mode, unlock all[01.360]loading environment from sunxi_flash... ok[01.369]try to burn key[01.372]out of usb burn from boot: not need burn keyhit any key to stop autoboot: 0sunxi work mode=0x10run usb efexdelay time 2500weak:otg_phy_configusb init okset address 0xeset address 0xe oksunxi_efex_erase_tagerase_flag = 0x12origin_erase_flag = 0x1fex_cmd_fes_verify_statusfex_cmd_fes_verify last err=0the 0 mbr table is ok*************mbr dump***************total mbr part 9part[0] name :envpart[0] classname :diskpart[0] addrlo :0x20part[0] lenlo :0x8part[0] user_type :32768part[0] keydata :0part[0] ro :0part[1] name :env-redundpart[1] classname :diskpart[1] addrlo :0x28part[1] lenlo :0x8part[1] user_type :32768part[1] keydata :0part[1] ro :0part[2] name :arm-lpsrampart[2] classname :diskpart[2] addrlo :0x30part[2] lenlo :0x960part[2] user_type :32768part[2] keydata :0part[2] ro :0part[3] name :rv-lpsrampart[3] classname :diskpart[3] addrlo :0x990part[3] lenlo :0xfa0part[3] user_type :32768part[3] keydata :0part[3] ro :0part[4] name :dsp-hpsrampart[4] classname :diskpart[4] addrlo :0x1930part[4] lenlo :0x640part[4] user_type :32768part[4] keydata :0part[4] ro :0part[5] name :rtos-xippart[5] classname :diskpart[5] addrlo :0x1f70part[5] lenlo :0x1388part[5] user_type :32768part[5] keydata :0part[5] ro :0part[6] name :arm-bpart[6] classname :diskpart[6] addrlo :0x32f8part[6] lenlo :0x960part[6] user_type :32768part[6] keydata :0part[6] ro :0part[7] name :configpart[7] classname :diskpart[7] addrlo :0x3c58part[7] lenlo :0x20part[7] user_type :32768part[7] keydata :0part[7] ro :0part[8] name :udiskpart[8] classname :diskpart[8] addrlo :0x3c78part[8] lenlo :0x0part[8] user_type :33024part[8] keydata :0part[8] ro :0need erase flash: 18the chip erase size is: 16m ...sunxi_efex_mbr_tagmbr size = 0x4000write primary gpt successspinor: skip backup gpt[43.156]update partition mapfex_cmd_fes_verify_statusfex_cmd_fes_verify last err=0fex_cmd_fes_verify_value, start 0x20, size high 0x0:low 0x1000fex_cmd_fes_verify_value 0x8c999e79fex_cmd_fes_verify_value, start 0x28, size high 0x0:low 0x1000fex_cmd_fes_verify_value 0x8c999e79fex_cmd_fes_verify_value, start 0x30, size high 0x0:low 0x121e48fex_cmd_fes_verify_value 0xe3775740fex_cmd_fes_verify_value, start 0x1930, size high 0x0:low 0x7a168fex_cmd_fes_verify_value 0x3b80dabdfex_cmd_fes_verify_value, start 0x1f70, size high 0x0:low 0x23c230fex_cmd_fes_verify_value 0x8bdd937bfex_cmd_fes_verify_value, start 0x32f8, size high 0x0:low 0xe8338fex_cmd_fes_verify_value 0x3e12775cfex_cmd_fes_verify_value, start 0x3c58, size high 0x0:low 0x3c00fex_cmd_fes_verify_value 0xe5de21cflash sectors: 0x8000fex_cmd_fes_verify_value, start 0x3c78, size high 0x0:low 0x7e5400fex_cmd_fes_verify_value 0x4536d51fbootfile_mode=4sunxi_efex_boot1_tagboot1 size = 0x8000, max size = 0x80000uboot size = 0x124000storage type = 3skip toc1fex_cmd_fes_verify_statusfex_cmd_fes_verify last err=0bootfile_mode=4sunxi_efex_boot0_tagboot0 size = 0xc080storage type = 3burn first boot0 ok!burn boot0 redund ok!fex_cmd_fes_verify_statusfex_cmd_fes_verify last err=0sunxi_efex_next_action=2exit usbnext work 2sunxi_update_next_action_rebootfree spi flashuart 烧写r128 支持使用 uart 烧写系统。
请注意:r128 module 在硬件上下拉了 pa2 引脚,默认配置为usb下载模式。如果希望使用 uart 下载需要摘除 pa2 下拉电阻,或者外部上拉 pa2 到 3v3
pa2 下拉电阻为 47k,可以直接上拉 pa2 到 3v3 进入uart下载模式
uart 下载设置打开 phoenixmc 点击 刷新 ,注意在下载过程中请断开各类串口监视器,不能占用串口,否则刷新找不到对应串口。配置串口波特率,一般选择 1500000 即可如果选择太高的波特率会导致通讯错误,板载的 ch340c 仅支持最大2000000波特率
点击 刷新 选择对应的串口点击调试进入调试界面
如果出现 open uart error! 则表示没有关闭串口助手或者选择错了串口。
配置 flash 长度,例如 r128 内置 16m nor flash,这里就填入 0x1000000 也就是 16m 长度烧写前先擦除 flash点击写入
选择 16m 固件,注意这个固件后缀名是 .bin ,不是 usb 烧写的 .img 文件注意:usb 烧写使用的是专有格式,需要 phoenixsuit 解析并烧录,uart 烧写使用的是通用格式,为内置 spi nor 的镜像文件。
提示文件较小,点击确定即可
开始烧写
烧写完成,下载结束
uart mboot 通讯协议hostmain-cmdsub-cmdcmd valuedescriptionremarks
pc 0x00 0x00 0x00 read 1 byte
pc 0x00 0x01 0x01 write 1 byte
pc 0x00 0x02 0x02 read 2 bytes
pc 0x00 0x03 0x03 write 2 bytes
pc 0x00 0x04 0x04 read 4 bytes
pc 0x00 0x05 0x05 write 4 bytes
pc 0x00 0x06 0x06 read 8 bytes
pc 0x00 0x07 0x07 write 8 bytes
pc 0x01 0x00 0x08 read n bytes
pc 0x01 0x01 0x09 write n bytes
pc 0x02 0x00 0x10 change the uart transmission condition
pc 0x02 0x01 0x11 enable/disable jtag
pc 0x02 0x02 0x12 reboot
pc 0x02 0x03 0x13 set pc pointer
pc 0x02 0x04 0x14 enable/disable mcu transmission and validation
pc 0x02 0x05 0x15 obtain baud rate list
pc 0x02 0x06 0x16 modify the buffer
pc 0x00 0x00 0x18 obtain flash information
pc 0x01 0x01 0x19 chip erase
pc 0x01 0x02 0x1a read n sectors
pc 0x01 0x03 0x1b write n sectors
pc 0x01 0x04 0x1c obtain flash information
pc 0x01 0x05 0x1d chip erase
pc 0x01 0x06 0x1e read n sectors
pc 0x01 0x07 0x1f write n sectors
mcu 0x00 0x00 send message to pc
烧录速度对比烧录方式擦除速度烧录速度
usb 30s 38s
uart (1500000) 60s 205s
uart (115200) 60s 1466s


海默机器人全新机器人编程系统EngSign 5.0重磅发布
中芯国际上调全年收入增长预期23%-25%
杭州水务热线呼叫中心升级 提高客服处理效率
室内LED灯泡需要更可靠的电路保护
工程机械远程监控运维平台助力作业安全监管
DshanMCU-R128s2 烧写固件
MIC2550应用电路
IGBT智能化驱动板SCALE
Facebook数据泄露丑闻之后风波不断 脸书再遭数据泄露
通过ANSYS仿真加速度计设计复合量程微加速度计并进行动态特性测试
CATL成为特斯拉的电池供应商
锂离子电池的安全性技术发展趋势分析
PS5的创新重点:DualSense的一些外围表现引发话题
一体成型电感的应用是怎样的
三季度全球电视面板备货旺季启动,超大尺寸面板价格有望止跌
英特尔公布三项全新技术 将为芯片产品架构开启一个全新维度
威迈斯IPO上市:聚焦行业发展 加码自动化生产布
高光谱图像对矿产资源种类的深度识别方法
最强性能机iQOO Neo3发布,售价2698元起
高性能电子设计:电磁干扰仿真预测方法