完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,社区,一个星期我现在试图获得串行引导装载机运行的PIC16F18324,但目前还没有成功,希望你能帮助我。闪光灯的微控制器,我使用统一的Bootloader应用0.1.14,使用Bururt为9600。我用MCC产生8位。Bootloader并遵循本文档的所有指令:http://WW1.Microchip .com /…EVICEDOC/4001779B.PDFI,使用逻辑分析仪(http://wwwsalea.com /下载)来嗅探通信(日志也附上)。我尝试闪存完全相同的固件已经在微控制器上存在。日志显示闪动PIC似乎对一些数据块(0x01)起作用,对于其他数据块则不(0xFE)。Bootloader也似乎停在中间的某个地方,这导致校验和在最后不匹配。此外,当在开始时发送擦除命令(0x03)时,PIC也用“地址错误(0xFE)”来回答,但是主机应用程序说擦除是成功的,这使我感到困惑。这就是我在MCC生成的源代码和项目设置中所改变的:1。由于我不能编译这个项目,所以我做了评论NVMADR和NVMADT,因为它们已经在PIC16F18324.H中定义,但是有不同的值。2。我改变了重置和中断向量:正如这个HTTPS://www. McCHIP.COM/FUMMS/M960192.ASPX中所描述的,我还将引导加载程序偏移量和程序内存大小乘以2到0x800和0x8000。但这样做之后,我甚至无法获得Bootloader的读取版本,所以我猜想它已经覆盖了PIC。3的引导加载程序部分。我删除了函数来直接启动。我现在没有将RTS连接到MCLR以保持引导加载程序运行。我的计划是一旦启动成功,就给引导加载程序一个“跳转到应用程序”命令。要从应用程序运行引导加载程序,我想通过软件或硬件来重置设备,如果需要的话。4。我关掉了WDT5。从文档中描述的Bootloader应用程序中删除了所有配置位。我的主要应用程序(只是闪烁的LED)设置如下:6。由于校验和总是0x00,所以我在Microchip论坛中查看了:HTTP://www. MicroChIP.COM/FUMMS/M98264.ASPXSO,而不是OFI使用:现在我得到校验和,但是主机应用程序和PIC16F18324的校验和仍然不匹配,如预期的那样。7。Bootloader应用程序内存范围“0~400”8。对我来说,主机应用程序确实解决了微芯片的错误区域。如果你能帮助我并告诉我我缺少什么,那就太好了。我附上了以下文件:Bootloader项目的所有C和H文件。F主机应用程序的测试HEX文件,主机和设备之间的合并BooLoad通信日志(读取的免费软件“逻辑”:(http://wwwalalay.com /下载))
以上来自于百度翻译 以下为原文 Hi Community, for a week now I am trying to get the the serial bootloader running for the PIC16F18324 but had no success so far and hope you can help me. For flashing the microcontroller I am using the Unified Bootloader Application 0.1.14, using a Baurate of 9600. I used the MCC to generate the 8-bit bootloader and followed all instructions of this document: http://ww1.microchip.com/...eviceDoc/40001779B.pdf I use a logic analyzer (https://www.saleae.com/downloads) to sniff the communication (log also attached). I try to flash exactly the same firmware as already existent on the microcontroller. The logs show that flashing the PIC seems to work for some data blocks (0x01) and for others it doesn’t (0xFE). The bootloader also seems to stop somewhere in the middle, which results in checksums that do not match at the end. Furthermore, when sending the Erase Command (0x03) in the beginning, the PIC also replies with „address error (0xFE)“, however the Host Application says the Erase was successful, which confuses me. This is what I have changed in the MCC generated source code and project settings so far: 1. Since I was not able to compile the project, I did out comment NVMADR and NVMDAT, since they are already defined in the pic16f18324.h, however have different values. // Register: NVMADR // extern volatile uint16_t NVMADR @ 0x81A; // pic16f18324: extern volatile unsigned short NVMADR @ 0x891; // Register: NVMDAT // extern volatile uint16_t NVMDAT @ 0x81C; // pic16f18324: extern volatile unsigned short NVMDAT @ 0x893; // this should be in the device .h file. // extern volatile uint16_t NVMDATA @0x81C; 2. I changed the reset and interrupt vector: #define NEW_RESET_VECTOR 0x400 #define NEW_INTERRUPT_VECTOR 0x404 As described in this post https://www.microchip.com/forums/m960192.aspx I have also multiplied the boot loader offset and program memory size by 2 to 0x800 and 0x8000. But doing this, I was afterwards not even able to get the Read Version of the bootloader so I guess it has overwritten the bootloader section of the PIC. 3. I removed the Bootloader_Required() function to start the Run_Bootloader() directly. I did not connect RTS to MCLR for now to keep the Bootloader running. My plan is to give the boot loader a „Jump to application“ command, once the flashing was successful. To run the bootloader from the application, I want to reset the device by software or hardware, if required. 4. I turned off the WDT 5. I removed all configuration bits from the bootloader application as described in the document. My main application (just a blinking LED) setup is like this: // CONFIG1 #pragma config FEXTOSC = OFF // FEXTOSC External Oscillator mode Selection bits->Oscillator not enabled #pragma config RSTOSC = HFINT1 // Power-up default value for COSC bits->HFINTOSC (1MHz) #pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled; I/O or oscillator function on OSC2 #pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled // CONFIG2 #pragma config MCLRE = ON // Master Clear Enable bit->MCLR/VPP pin function is MCLR; Weak pull-up enabled #pragma config PWRTE = OFF // Power-up Timer Enable bit->PWRT disabled #pragma config WDTE = OFF // Watchdog Timer Enable bits->WDT disabled; SWDTEN is ignored #pragma config LPBOREN = OFF // Low-power BOR enable bit->ULPBOR disabled #pragma config BOREN = ON // Brown-out Reset Enable bits->Brown-out Reset enabled, SBOREN bit ignored #pragma config BORV = LOW // Brown-out Reset Voltage selection bit->Brown-out voltage (Vbor) set to 2.45V #pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit->The PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a Reset #pragma config DEBUG = OFF // Debugger enable bit->Background debugger disabled // CONFIG3 #pragma config WRT = OFF // User NVM self-write protection bits->Write protection off #pragma config LVP = OFF // Low Voltage Programming Enable bit->Low Voltage programming disabled // CONFIG4 #pragma config CP = OFF // User NVM Program Memory Code Protection bit->User NVM code protection disabled #pragma config CPD = OFF // Data NVM Memory Code Protection bit->Data NVM code protection disabled 6. Since the checksum was always 0x00 I had a look in the microchip forums: http://www.microchip.com/forums/m988264.aspx So instead of check_sum += (uint16_t)NVMDATA; // Using NVMDAT would work here as well I use: check_sum += NVMDATL; check_sum += (NVMDATH<<8); Now I get a checksum, but the checksum of the host application and PIC16F18324 still do not match, as expected. 7. Memory Range of the Bootloader application „0-400“ 8. Codeoffset of application „0x400“ So for me it looks like the host application does address the wrong areas of the microchip. It would be great if you could help me and tell me what I am missing. I attached the following files:
Bootloader-Attachments.zip (214.87 KB) - downloaded 41 times |
|
相关推荐
6个回答
|
|
嗨,丹尼,首先,感谢你提供的详细信息。第1点。):NVMADR和NVMADT的PIC16F18324.H的定义是正确的(数据表4-4表。点2):新的重置和中断向量对我来说似乎很好(如果您的引导加载程序没有占用更多的程序空间)超过0x000。在统一引导加载程序主机应用程序中,将地址乘以2是应该的方法。这也解决了我在我提到的线程中所提到的问题。看看你的附件,你使用了一个0x400的引导加载程序。将它改为0x800,0x4000内存大小太多了!当你使用0x8000之前,这只是使它更糟(PIC你只使用了4096字节的程序内存,所以结束地址是0x0FFF)。使用0x2000内存大小。实际上,你的PIC上的MCC Bootloader应该防止重写自己,检查函数“Read Effer())。在最上面你应该看到这样的东西:第3点。)你可以做到。还可以提供多种方法来“跳转”到引导加载程序。例如,我实现了一个软件引导加载条目(从应用程序重写NexIsReType向量并执行一个软件ReSET())。请记住,当损坏的固件闪现时,此解决方案失败。在这种情况下,你将无法进入你的引导加载程序了。出于这个原因,我另外实现了一个硬件条目(Bootloader检查一个低状态引脚,它是通过内部上拉来初始化的)。点4。我不认为这是必要的。点5。只要您将引导加载程序与主应用程序一起闪动,省略引导加载程序。配置是走的路。但是,如果你正在闪动Bootloader,那么你也需要配置。但是我想这很清楚。第6点。你也可以尝试重做你的修改,使用NVMAT而不是NVMDATA吗?你正在使用的PIC有相当少量的内存。在使用Bootloader时,应该考虑切换到更大的版本,因为这占用了整个程序内存的25%。如果这还不够,请参阅PIC16F18325,甚至PIC16F18326。
以上来自于百度翻译 以下为原文 Hi Danny, At first, thanks for the detailed Information you provided. Point 1.): The definitions from pic16f18324.h of NVMADR and NVMDAT are correct (See TABLE 4-4 of the datasheet). Point 2.): The new reset and interrupt vectors seem good to me (provided your bootloader does not take more program space than 0x0000 .. 0x03FF Multiplying the addresses by 2 in the Unified Bootloader Host application should be the way to go. This also solved the issues I had as I stated in my thread you referred to. Looking at your attachment you have used a bootloader offset of 0x400. Change that to 0x800, 0x4000 for the memory size is too much! When you used 0x8000 before, that was just making it worse (The PIC you are using only has 4096 Bytes of program memory, so end address is 0x0FFF). Use 0x2000 for the memory size. Actually the MCC bootloader on your PIC should prevent overwriting itself, check the function 'Write_Flash()' . At the very top you should see something like this: if ((NVMADR & 0x1FFF) < NEW_RESET_VECTOR) { frame.data[0] = ERROR_ADDRESS_OUT_OF_RANGE; return (10); } Point 3.) You can do that. You can also provide multiple ways to 'jump' to your bootloader. For example I implemented a software bootload entry (overwriting the NEW_RESET_VECTOR from the application and performing a software RESET()). Keep in mind though that this solution fails when a corrupted firmware has been flashed. In that case you wont be able to enter your bootloader anymore. For this reason I additionally implemented a hardware entry (bootloader checks for a low state pin which is initialised with internal pull-up on reset). Point 4.) I don't think that is necessary. Point 5.) As long as you flash the bootloader together with your main application, omitting the bootloaders configuration is the way to go. If however you are flashing the bootloader stand alone, you will need the configuration as well. But I guess that's clear. Point 6.) Can you also try to redo your changes and use NVMDAT instead of NVMDATA? The PIC you are using has quite a small amount of memory. You should consider switching to a bigger version when using the bootloader, as this takes 25% of your overall program memory. If that is not enough, look at PIC16F18325 or even PIC16F18326. Regards Fabian EDIT: corrected error in bootloader address range. |
|
|
|
嗨,Fabian,谢谢你的详细回答。2)我的一个愚蠢的错误。谢谢!使用0x800和0x2000为我工作。第6点)它对我起作用。再次感谢,祝你周末愉快,Doa。
以上来自于百度翻译 以下为原文 Hi Fabian, thanks for your detailed reply. Point 2) What a stupid mistake from my side. Thanks a lot! Using 0x800 and 0x2000 works for me. Point 6) It works both ways for me. Thanks again and have a good weekend, Doa |
|
|
|
嗨,Doa,很高兴听到它现在起作用了。有时候人们会对显而易见的东西视而不见,尤其是当论坛中关于某个主题已经有很多混乱的时候。你以前使用DATL和DAH的修复实际上是指数据寄存器被定义为8位的设备。在设备特定的头文件中注册(指向与DATL相同的位置)。祝你周末愉快,Fabien。
以上来自于百度翻译 以下为原文 Hi Doa, good to hear that it works now. Sometimes one just gets blind to the obvious, especially when there is already a lot of confusion around in the forums about a subject. The fix you previously applied using DATL and DATH was actually meant for devices where the DATA register is defined as 8 bit register (pointing to the same location as DATL) in the device specific header file. Good weekend to you as well, Fabien |
|
|
|
恭喜你的工作和做功课的强烈工作。FabianL对第2点的回答是“如何使它工作”的问题。主机不知道哪个设备在那里,并接受输入的值作为正确的内存大小。这是“为什么它这样做”:看看擦除命令并找到这个代码片段。if((nvMAD&&;0x7f)& gt;= Enthflash)代码试图擦除超出Pro的结尾。克空间。当上面的点2尝试了0x8000的程序大小时,它在0x1000之后命中了这个条款。应用程序区域的擦除是成功的,但是它命中了这个命令并中止了命令。在添加这个测试之前,程序计数器会滚动并擦除引导加载程序。显然,擦除命令永远不会被主机确认。主机超时并报告丢失的通信。至少这样,它不会擦除引导加载程序。
以上来自于百度翻译 以下为原文 Congrats on getting it working and strong work on doing your homework first. FabianL's answer to point 2 nails the "how to make it work" question. The host doesn't know which device is out there and accepts the entered value as the proper memory size. This is the "why it did that": Take a look at the Erase command and find this snippet of code. for (uint16_t i=0; i < frame.data_length; i++) { if ((NVMADR & 0x7F) >= END_FLASH) { frame.data[0] = ERROR_ADDRESS_OUT_OF_RANGE; return (10); } The if ((NVMADR & 0x7F) >= END_FLASH) code tests for an attempt to erase beyond the end of program space. When point 2 above tried a program size of 0x8000, it hit this clause after 0x1000. The erase of the application area was successful, but it hit this and aborted the command. Before we added this test the program counter would roll over and erase the bootloader. Obviously the erase command would never be acknowledged to the host. The host times out and reports lost communication. At least this way it doesn't erase the bootloader. |
|
|
|
“有趣的子句,感谢添加了一点信息。假设我在1:”NexyReStIdApple & lt;0x7f2)失败了,那么EraseElFlasyBlaskSigel& G.64 i知道这可能不是这样的,但是它不足以使用吗?费边主义
以上来自于百度翻译 以下为原文 Interesting clause, thanks for adding that bit of information. Am I right assuming that this fails when either: 1.) NEW_RESET_VECTOR < 0x7F 2.) ERASE_FLASH_BLOCKSIZE > 64 I know this is probably never the case but wouldn't it suffice to use: if ((NVMADR & ((ERASE_FLASH_BLOCKSIZE << 1 ) - 1)) >= END_FLASH) instead? Regards Fabian |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3214 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2261 浏览 5 评论
781浏览 1评论
676浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
602浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
684浏览 0评论
581浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 08:42 , Processed in 1.546637 second(s), Total 87, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号