完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我写了自己的Bootloader为DSPIC33 EV系列。我用一个小应用程序测试了几个LED,并有其他功能散布在整个程序存储器中,但是我尝试闪亮一个更大的固件,固件在应用程序的启动代码中被卡住,检查RCON显示IopuWR位是在STARTU中的某个点设置的。Bootloader的体系结构是这样的:Bootloader位于前8页(我计划使用CODEGARID,只要我能在扇区内获得功能……这是另一个故事。)设备重置向量点在0x400,第1页,其中引导加载程序超过它自己的启动代码。易失性const int属性((地址(0x200))RES(256)={ 0,};是这样的,编译器认为第0页的第0页实际上被占用,没有代码被放置在0x200和0x中。应用重置向量在0x2000。设备引导。EXECUTE Bootloader启动代码,进入Bootloader MIN。在主程序中,如果一个特定的PIN被短路到地上,在这种情况下它将进入Bootloader,如果不是,那么它检查在0x2000是否有一个有效的操作码(如果它与0xFFFFFF不同)。如果没有有效的操作码,它将开始执行引导加载程序,否则将在0x2000跳到0x2000,然后启动应用程序启动代码。我确信这一点,因为在应用程序中,我做了同样的事情来保留StaseDeavyListconst int属性((地址(0x200))RES(3840)={ 0,};并且编译后的HEX确实有一个Goto 0x2000作为复位向量,在0x200和0x1FFFF过程中没有代码存在,当下载应用程序时,WH。EnBootloader写到第0页,第0行,它将用一个NOP替换Goto 0x400跟随器的App Read vector。我用两个简单的固件测试Bootloader,它将以不同的模式闪烁LED,它工作了。然后我尝试使用一个更复杂的应用程序(一个可以运行的应用程序)。LLY使用在这个板上,但是MCU不能通过应用程序启动代码:直到它退出引导加载程序才能正常运行,然后它在第二个启动代码中停留在某个地方,重新启动并且循环继续下去。我从设备上上传了代码,并验证了它实际上是引导加载程序代码和应用程序代码的结合。我将十六进制与另外两个代码进行了比较,并与预期的一样:-将重置向量引导到引导程序-从应用程序-引导程序代码从0x400到0x1FFF的中断向量。-从0x2000到结束的应用程序代码。然后我打开了HEX作为X(PrimBudieHEX)中的一个新项目并点击调试器。在某个点重置,检查RCON之前和之后显示IOUWWR位是设置非法代码检测或非法地址模式,或者作为地址指针使用的未初始化W寄存器导致RESEti然后进行此测试:我编辑了HEX文件,使启动向量为0x2。000(绕过Bootloader),应用程序启动得很好。我真的不知道如何进行。
以上来自于百度翻译 以下为原文 Hi, i wrote my own bootloader for dsPIC33EV series. I tested with a small application that blinks a couple of LEDs and has other functions scattered across whole program memory, but then i tried flashing a bigger firmware and firmware gets stuck during application's startup code, Checking RCON shows that IOPUWR bit is set at some point during startup. Deeper explanation: The bootloader architecture is such: Bootloader is located in the first 8 pages (i plan to use codeguard as soon as i can get functions to work inside sectors... that's another story.) device reset vector points at 0x400, page 1, where the bootloader excecute its own startup code. volatile const int __attribute((address(0x200))) res[256] = {0,}; is present so the compiler thinks second half of page 0 is actually occupied and no code is placed from 0x200 and 0x3FF. Application reset vector is at 0x2000. Device boots. Excecutes bootloader startup code, enters bootloader main. inside main it checks if a particular pin is shorted to ground, in that case it will enter bootloader, if not then it checks if there is a valid opcode at 0x2000 (if it's different than 0xFFFFFF). If no valid opcode is there it will start doing bootloader stuff, otherwise it will jump to 0x2000 At 0x2000 then starts the application startup code. I am sure of this because in the application i did the same thing to reserve space volatile const int __attribute((address(0x200))) res[3840] = {0,}; and the compiled hex does have a goto 0x2000 as reset vector, no code is present between 0x200 and 0x1FFF Of course, when downloading an application, when bootloader writes to Page 0, Row 0 it will substitute the app reset vector with GOTO 0x400 follower by a NOP. I tested the bootloader with a couple of simple firmwares that would blink leds in different patterns, it worked. I then tried using a more complex application (the one that would be actually used in this board) but the MCU can't get past the application startup code: it goes fine until it exits the bootloader, then it gets stuck somewhere during the second startup code, reboots and the cycle goes on forever. What i did to veryfy this: along using led patterns to identify where it got stuck, i uploaded the code from the device, and verified that it is effectively the union of the bootloader code and the application code. I diff'd the hex with the other two and it is as expected: - Reset vector to bootloader - Interrupt vectors from application - Bootloader code from 0x400 to 0x1FFF - Application code from 0x2000 till the end. I then opened the hex as a new project in X (prebuild hex) and hit the debugger. this way I confirmed that the bootloader goes through and it excecutes some of the startup code. At some point the part resets, checking RCON before and after shows that IOPUWR bit is set An Illegal Opcode detection or an Illegal Address mode, or Uninitialized W register used as an Address Pointer caused a Reset I then made this test: I edited the hex file so that the startup vector would be 0x2000 (bypass the bootloader) the application starts up fine. i really don't know how to proceed |
|
相关推荐
7个回答
|
|
|
|
|
|
事实上,我是这样做的,因为WDTO位也是被设置的,但是看门狗是由SWDTEN位控制的(并且在配置词中适当地设置),并且在进入应用程序之前已经被清除了。实际上,Bootloader的最后四个指令是
以上来自于百度翻译 以下为原文 I actually tought about it because WDTO bit is also set, but Watchdog is controlled by SWDTEN bit (and set up accodingly in configuration words) and it's cleared before going into the application anyway. Infact, the last four instructions of the bootloader are BCLR RCON,#5 CLRWDT GOTO 0x2000 NOP |
|
|
|
我要检查的第一件事是确保应用程序启动代码在0x2000。你可以打开.map文件并搜索类似的东西:在我的例子中,我的应用程序的入口点是0x1200。你使用了任何自定义链接器脚本吗?你给我的印象是你没有。
以上来自于百度翻译 以下为原文 The first thing I'll check is to make sure the application startup code is at 0x2000. You can open the .map file and search for something like: In my case, my application's entry point is 0x1200. Are you using any custom linker script? You gave me the impression that you don't. |
|
|
|
它可能是你的启动尝试访问(写,但也可以读取)一些内存位置,由于一些以前的引导装载行动的保护?我似乎记得只能设置一次的寄存器(如果配置位这么说)。这将完美地解释为什么它独立工作,但在引导加载程序之前是不活动的。
以上来自于百度翻译 以下为原文 Could it be your startup tries to access (write but could be read as well) some memory location that is protected due to some prior bootloader action? I seem to recall registers that can only be set once (if the config bits say so). This would perfectly explain why it's working standalone, but not when the bootloader was active before. |
|
|
|
启动实际上是在0x2000,我可以通过查看HEX文件(第一行是Goto 0x2000和没有实际固件在Bootloader空间内)来查看,无论如何,从MAP文件中可以看到:第一部分是一组分配的无意义数据,以便编译器将启动代码放置在别处。我倾向于认为这不是问题,因为较小的测试固件Bootloader工作设置了配置位,使得多个重新配置(振荡器、PPS、PWM)是可能的。
以上来自于百度翻译 以下为原文 Startup is indeed at 0x2000, i can see that by looking at the hex file (first line is GOTO 0x2000 and none of the actual firmware is inside bootloader space) anyway, from the map file: The first section is a bunch of nonsense data allocated there so that the compiler places the startup code elsewhere. I am inclined to think that it is not a problem because with smaller test firmwares the bootloader works The configuration bits are set so that multiple reconfigurations (of Oscillator, PPS, PWM) are possible |
|
|
|
因为在编辑时愚蠢的“访问被拒绝”的双重发布很明显在引导加载程序中发生了一些导致错误的事情,但是我想不出它可能是什么。现在,我将在块之间进行单步尝试,以确定故障发生的时间,但我尝试编辑链接器脚本,当然,我删除了用于保留空间的变量。生成的代码是正确的,没有任何东西从0x200到0x1FFF,同样的问题。
以上来自于百度翻译 以下为原文 double posting because stupid "Access Denied" while editing It is clear that there is something that happens in the bootloader that causes the fault, but i can't think of what it could be. Now i'll single step between blocks to try to localize at which moment the fault appears no luck yet, but i tried editing the linker script /* Original: program (xr) : ORIGIN = 0x200, LENGTH = 0x2A980 Modified: */ program (xr) : ORIGIN = 0x2000, LENGTH = 0x28B80 and of course i removed the variable used to reserve space. Generated code is correct, nothing is placed from 0x200 to 0x1FFF, same problem |
|
|
|
不能再编辑我的帖子(叹气)。我想我发现了问题。用一个稍微修改过的应用固件,与原来的HEX相去甚远,我注意到有一堆分散在文件周围,旁边的预期。然后我去检查我的Windows应用程序,在HEX文件解析器中有一个bug。我忘了添加一个检查数据行中有多少字节(D'OH),因为有一些行少于4个程序字,有时校验和将写在HEX文件上,因此非法OpCODES.我是怎么错过的,我不知道…总之,谢谢大家:
以上来自于百度翻译 以下为原文 can't edit my post again (sigh) I think i found the problem..with a slightly modified application firmware, diffing with the original hex i noticed that there were a bunch of diffs scattered around the file, beside the expected ones. I then went to check my windows application, there was a bug in the hex file parser.. i forgot to add a check for how many data bytes were left in the row (d'oh) and since there were some rows with less than 4 program words, sometimes the checksum would be written on the hex file, hence the illegal opcodes. how did i miss that i don't know.. Anyway, thank you all :) |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
727浏览 1评论
612浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
501浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
626浏览 0评论
524浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 07:22 , Processed in 1.278518 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号