完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我正在努力在这个PIC上运行Bootloader。这是我第一次使用GA705,但过去我用PoToLoad使用了其他PIC24FJ和PIC24EPS。这个Bootloader和应用程序使用以前已经成功使用的现有代码库。Flash的第一页是Goto & lt;应用& GT;然后是中断向量表的指令。第二页的Flash,从地址0x400开始,保留给应用程序写一些信息。Bootloader使用此信息来确定是否需要引导加载程序,验证CRC等。但是,当我调用Flash的第一页时,将被擦除。我已经证实,我没有调用任何闪存擦除功能。事实上,应用程序永远不会擦除Flash,只有Bootloader允许这样做。我还没有将引导加载程序编程到芯片中。我的配置位:我认为这是一个相当新的处理器,它有一些额外的读写FLASH的安全性。但我想我已经失去了安全。我也不知道为什么它会抹掉一个闪存页面由于安全设置……我错过了什么?
以上来自于百度翻译 以下为原文 I'm working on getting a bootloader operational on this PIC. It is the first time I've used the GA705, but I've used other PIC24FJ and PIC24EPs with bootloaders in the past. This bootloader and application project uses an existing code base that has been used previously with success. The first page of flash is the GOTO #define APP_DATA_PAGE (0x000400UL) #define APP_REQUEST_FLAG_ADDR (APP_DATA_PAGE) //!< Request flag location in program memory. #define APP_REV_NBR_ADDR (APP_REQUEST_FLAG_ADDR + 4) //!< Address where the application stores its version number #define APP_SVN_NBR_ADDR (APP_REV_NBR_ADDR + 4) //!< Address where the application stores its SVN number #define APP_ENG_NBR_ADDR (APP_SVN_NBR_ADDR + 8) //!< Address where the application stores its engineering number #define APP_PART_NBR_ADDR (APP_ENG_NBR_ADDR + 4) //!< Address where the application stores its part number _write_flash_word24 (APP_REQUEST_FLAG_ADDR, APP_OK_BOOTLOADER_FLAG); while (NVMCONbits.WR); The first page of flash is erased. I've verified that I am not calling any flash erasing functions. In fact, the application will never erase flash, only the bootloader is allowed to do so. I have not yet programmed the bootloader into the chip yet. My configuration bits: // FSEC #pragma config BWRP = OFF // Boot Segment Write-Protect bit (Boot Segment may be written) #pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits (No Protection (other than BWRP)) #pragma config BSEN = OFF // Boot Segment Control bit (No Boot Segment) #pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written) #pragma config GSS = DISABLED // General Segment Code-Protect Level bits (No Protection (other than GWRP)) #pragma config CWRP = OFF // Configuration Segment Write-Protect bit (Configuration Segment may be written) #pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits (No Protection (other than CWRP)) #pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit (Disabled AIVT) // FBSLIM #pragma config BSLIM = 0x1FFF // Boot Segment Flash Page Address Limit bits (Boot Segment Flash page address limit) // FSIGN // FOSCSEL #pragma config FNOSC = FRC // Oscillator Source Selection (Internal Fast RC (FRC)) #pragma config PLLMODE = DISABLED // PLL Mode Selection (No PLL used; PLLEN bit is not available) #pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source) // FOSC #pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled) #pragma config OSCIOFCN = ON // OSC2 Pin Function bit (OSC2 is general purpose digital I/O pin) #pragma config SOSCSEL = OFF // SOSC Power Selection Configuration bits (Digital (SCLKI) mode) #pragma config PLLSS = PLL_FRC // PLL Secondary Selection Configuration bit (PLL is fed by the on-chip Fast RC (FRC) oscillator) #pragma config IOL1WAY = OFF // Peripheral pin select configuration bit (Allow multiple reconfigurations) #pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled) // FWDT #pragma config WDTPS = PS8192 // Watchdog Timer Postscaler bits (1:4096) #pragma config FWPSA = PR32 // Watchdog Timer Prescaler bit (1:32) #pragma config FWDTEN = ON // Watchdog Timer Enable bits (WDT Enabled) #pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode) #pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits (WDT Window is 25% of WDT period) #pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits) #pragma config WDTCLK = LPRC // WDT Clock Source Select bits (WDT uses LPRC) // FPOR #pragma config BOREN = ON // Brown Out Enable bit (Brown Out Enable Bit) #pragma config LPCFG = OFF // Low power regulator control (No Retention Sleep) #pragma config DNVPEN = ENABLE // Downside Voltage Protection Enable bit (Downside protection enabled using ZPBOR when BOR is inactive) // FICD #pragma config ICS = PGD2 // ICD Communication Channel Select bits (Communicate on PGEC2 and PGED2) #pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled) // FDEVOPT1 #pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit (C1INC, C2INC, and C3INC are on their standard pin locations) #pragma config TMPRPIN = OFF // Tamper Pin Enable bit (TMPRN pin function is disabled) #pragma config SOSCHP = OFF // SOSC High Power Enable bit (valid only when SOSCSEL = 1 (Enable SOSC low power mode) #pragma config ALTI2C1 = ALTI2CEN // Alternate I2C pin Location (SDA1 and SCL1 on RB9 and RB8) I think this is a fairly new processor, and it has some additional security for reading/writing flash. But I think I have that security disabled. I also don't know why it would be erasing a page of flash due to security settings... Am I missing something? |
|
相关推荐
13个回答
|
|
|
这是一个大大简化的程序,它展示了一个问题:如果我在OnWrreWiFrasyWord24()上设置一个断点,调试器将停止它。我可以点击重置,点击运行,调试器将再次停止。我可以做到这一点,我的心内容。但是,如果我在SO WraveFlash的Word24()行,我按下步进,程序计数器将进展到while(1)语句。如果我再次中途停留,我会失去程序计数器。如果我按下重置,程序不会重置。如果我读Flash内容,除了配置位之外,整个芯片都会被擦除。如果我在SyWrreWiFrxWord24()行上,我按步骤(而不是进入),我立即失去程序计数器。如果我按下重置,程序不会重置。如果我读Flash内容,除了配置位之外,整个芯片被擦除。
以上来自于百度翻译 以下为原文 Here's a greatly simplified program that exhibits the issue: #include #include #define FCY 8000000 #include #if (__XC16_VERSION != 1032) #error This firmware has been built and tested with XC16 version 1.32 Please test everything thoroughly when using another version. #endif int main(void) { volatile uint8_t i; volatile uint8_t j; for (i = 0; i < 10; i++) { __delay_ms(10); j = i * 7; // Just something for me to step through to verify it is working } _write_flash_word24(0x10000, 0x00543210); while (1); return 0; } // 'C' source line config statements // FSEC #pragma config BWRP = OFF // Boot Segment Write-Protect bit (Boot Segment may be written) #pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits (No Protection (other than BWRP)) #pragma config BSEN = OFF // Boot Segment Control bit (No Boot Segment) #pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written) #pragma config GSS = DISABLED // General Segment Code-Protect Level bits (No Protection (other than GWRP)) #pragma config CWRP = OFF // Configuration Segment Write-Protect bit (Configuration Segment may be written) #pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits (No Protection (other than CWRP)) #pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit (Disabled AIVT) // FBSLIM #pragma config BSLIM = 0x1FFF // Boot Segment Flash Page Address Limit bits (Boot Segment Flash page address limit) // FSIGN // FOSCSEL #pragma config FNOSC = FRC // Oscillator Source Selection (Internal Fast RC (FRC)) #pragma config PLLMODE = DISABLED // PLL Mode Selection (No PLL used; PLLEN bit is not available) #pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source) // FOSC #pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled) #pragma config OSCIOFCN = ON // OSC2 Pin Function bit (OSC2 is general purpose digital I/O pin) #pragma config SOSCSEL = OFF // SOSC Power Selection Configuration bits (Digital (SCLKI) mode) #pragma config PLLSS = PLL_FRC // PLL Secondary Selection Configuration bit (PLL is fed by the on-chip Fast RC (FRC) oscillator) #pragma config IOL1WAY = OFF // Peripheral pin select configuration bit (Allow multiple reconfigurations) #pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled) // FWDT #pragma config WDTPS = PS8192 // Watchdog Timer Postscaler bits (1:4096) #pragma config FWPSA = PR32 // Watchdog Timer Prescaler bit (1:32) #pragma config FWDTEN = ON // Watchdog Timer Enable bits (WDT Enabled) #pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode) #pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits (WDT Window is 25% of WDT period) #pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits) #pragma config WDTCLK = LPRC // WDT Clock Source Select bits (WDT uses LPRC) // FPOR #pragma config BOREN = ON // Brown Out Enable bit (Brown Out Enable Bit) #pragma config LPCFG = OFF // Low power regulator control (No Retention Sleep) #pragma config DNVPEN = ENABLE // Downside Voltage Protection Enable bit (Downside protection enabled using ZPBOR when BOR is inactive) // FICD #pragma config ICS = PGD2 // ICD Communication Channel Select bits (Communicate on PGEC2 and PGED2) #pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled) // FDEVOPT1 #pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit (C1INC, C2INC, and C3INC are on their standard pin locations) #pragma config TMPRPIN = OFF // Tamper Pin Enable bit (TMPRN pin function is disabled) #pragma config SOSCHP = OFF // SOSC High Power Enable bit (valid only when SOSCSEL = 1 (Enable SOSC low power mode) #pragma config ALTI2C1 = ALTI2CEN // Alternate I2C pin Location (SDA1 and SCL1 on RB9 and RB8) If I put a breakpoint on _write_flash_word24(), the debugger will stop on it. I can hit reset, hit run, and the debugger will stop on it again. I can do this to my hearts content. However, if I am on the _write_flash_word24() line and I press step into, the program counter will progress to the while (1) statement. If I hit stop over again, I lose the program counter. If I press reset, the program does not reset. If I read the flash contents, the entire chip is erased except for the configuration bits. If I am on the _write_flash_word24() line and I press step over (instead of into), I immediately lose the program counter. If I press reset, the program does not reset. If I read the flash contents, the entire chip is erased except for the configuration bits. |
|
|
|
|
|
我在芯片上使用DEE数据仿真EPROM库,它们工作得很好。在包含文件中可能有一些错误,关于pGeLySead、EraseEXPGE以及类似的,我记得像他们这样的一些问题…
以上来自于百度翻译 以下为原文 I used DEE Data Emulation Eprom libraries on this chip and they worked fine. There could be some mistake in the include files, concerning PAGE_SIZE, ERASE_PAGE and alike, I remember some issue like them... |
|
|
|
|
|
好吧,可能你擦掉了Flash页面。你没有表现出来吗?我现在不能检查它,但是在PIC24FJGB1上擦除和写入闪存的过程(和代码),例如更新的PIC24FJGB4或6肯定是不同的。很容易的是,PIC24写代码是GB4的擦除代码,也适用于新的PIC。你必须检查一下。你可以在论坛中找到几个线程来处理这个问题。
以上来自于百度翻译 以下为原文 Well, possibly you DO erase the flash page. You didn't show _write_flash_word24() did you ? I cannot check it right now, but the procedure (and codes) to erase and write to the flash on a PIC24FJGB1 and e.g. the newer PIC24FJGB4 or 6 are definitely different. It could easily be that the PIC24 write code is an erase code for the GB4 and also for your newer PIC. You have to check. You can find several threads in the forum dealing with this. |
|
|
|
|
|
“如果我读了Flash内容,除了配置比特之外,整个芯片都会被擦除。”阅读不会抹去任何东西。为什么整个芯片会被擦除?
以上来自于百度翻译 以下为原文 "If I read the flash contents, the entire chip is erased except for the configuration bits." Reading does not erase anything. Why would the whole chip get erased? |
|
|
|
|
|
NVMCON,NVMADRU,NVMADR和NVMKEY和表RD / WRAL标准寄存器。请看第6章。
以上来自于百度翻译 以下为原文 NVMCON, NVMADRU, NVMADR and NVMKEY and table rd/wr All standard registers. Look at chapter 6. |
|
|
|
|
|
看起来像DEE(至少3版)使用自己的汇编代码来编写Flash。SuffReWixWord24()是一个编译器提供的函数,将24位数据写入Flash。DEE似乎没有使用编译器提供的功能。你没有表现出来吗?我没有为AxWreWiFrasyWord24()显示源代码,但它是一个编译器提供的函数。它应该是“工作”,这正是关键所在。如果我允许我的应用程序执行编译器提供的函数,则将写数据写入Flash,实际上是擦除Flash的第一页。我不应该这么做。我开了一张Microchip的机票,并提供了我的简化申请。如果他们回来说编译器没有问题,那么我会深入研究它们提供的SoxWruteFLASHWORDW24()函数的汇编代码,并将其与数据表进行比较,看看我是否能找出为什么要擦除Flash而不是写它。但在这一点上,我还有一些其他的任务要完成,然后我会回到这里。我感谢所有人的回复。
以上来自于百度翻译 以下为原文 It looks like DEE (at least version 3.0) uses its own assembly code for writing to flash. _write_flash_word24() is a compiler provided function to write 24 bits of data to flash. The DEE doesn't appear to use this functionality provided by the compiler. Well, possibly you DO erase the flash page. You didn't show _write_flash_word24() did you ? I did not show the source for _write_flash_word24(), but it is a compiler provided function. It should "just work." That's exactly the point. If I allow my application to execute the compiler provided function, _write_flash_word24(), which should write data to flash, it is actually erasing the first page of flash. It shouldn't be doing that. I've opened a ticket with Microchip and provided them with my simplified application. If they come back and say there isn't an issue with the compiler, then I'll dig into the assembly code for the _write_flash_word24() function they provide and compare it to the datasheet to see if I can figure out why it is erasing flash instead of writing it. But at this point, I've got some other tasks to finish up on this project and then I'll come back to it. I appreciate all of the responses everyone. |
|
|
|
|
|
这可能是个问题…LIbPIC30.H有如下:数据表在示例代码中有如下散布:因此,头文件具有WrxEXORD代码为0x400,而数据表的示例代码段表示0x400是页擦除。现在,我不信任数据表中的示例代码,但这肯定是值得深入研究的。
以上来自于百度翻译 以下为原文 This might be the issue... libpic30.h has the following: #define _FLASH_ERASE_CODE 0x4042 #define _FLASH_WRITE_ROW_CODE 0x4001 #define _FLASH_WRITE_WORD_CODE 0x4003 the datasheet has the following scattered around in example code: Step 1: Set the NVMCON register to erase a page. MOV #0x4003, W0 MOV W0, NVMCON Step 1: Set the NVMCON register to program 128 instruction words. MOV #0x4002, W0 Step 5: Set the NVMCON register to program two instruction words. MOV #0x4001, W10 So, the header file has the write_word code as 0x4003 while the datasheet's example code snippets states that 0x4003 is a page erase. Now, I don't trust the example code in datasheets, but this is certainly something worth investigating a little more. |
|
|
|
|
|
我几乎可以肯定的是,DarioG和你是正确的,因为编译器和库代码中没有正确定义的一些值。我开了一张Microchip的票,并让他们改正这些问题。这就是我们支付HPA的原因。谢谢。我会用他们的回复来更新这个。
以上来自于百度翻译 以下为原文 I'm almost certain that DarioG and you are correct in that there are some values that are not properly defined in the compiler and library code. I've opened a ticket with Microchip and will let them correct the issues. That's what we pay HPA for. Thanks. I'll update this with their response. |
|
|
|
|
|
外围图书馆停止。他们不会再更新它了。
以上来自于百度翻译 以下为原文 The peripherial library is discontinued. They will not be updating it anymore. |
|
|
|
|
|
参数是什么?使用写,你已经擦掉了你正在写的页面?一个页面不应该被擦除,有些奇怪的地方。如果你不能让它工作的话,写自己的RD/WR Flash函数是非常容易的。它已经有了纠错码(ECC),我认为这是在芯片内部的。
以上来自于百度翻译 以下为原文 What are the parameters to _write_flash_word24? Using write, then you have already erased the page you are writing into? A page should not have been erased, something strange there. It's farely easy to write your own rd/wr flash funcs if you can't get it working. It has got Error Correcting Code(ECC), I think this in internal to the chip. |
|
|
|
|
|
是的,我发现了这样的差异:数据表比库或包含文件更可信。
以上来自于百度翻译 以下为原文 Yep, I found such discrepancies: and the datasheet was more trustable than the libraries or include files. |
|
|
|
|
|
地址写入和24位数据。我的应用程序没有明确地擦除页面,但这并不重要,因为它已经被简单地擦除编程的部分。我有两个应用程序。第一个是我为客户开发的产品。应用程序将写入由于自定义链接器脚本而未使用的页。如果数据已被写入,应用程序将不会尝试再次写入它。最终,引导加载程序将删除该页,这将导致应用程序在下次启动时写入数据。程序在启动时除了延迟100MS之外什么都不做,然后写入地址为0x10000。地址0x10000是空白的,链接器没有把代码放在那里。但是它抹去了Flash的第一页。YUP,Flash的EraseEX代码,FLASHWORKEDYROWORY代码,以及FLASHWORDEWEXWORDYCODE的定义似乎是错误的。写字代码被定义为擦除代码,所以当写函数被调用时,它会擦掉Flash的第一页,因为指令是错误的。我要让Microchip处理它。我需要完成SD卡的支持。希望在今天结束之前我能工作,然后我回到Bootloader。如果Microchip没有回复我的汇编代码,那我就自己写。
以上来自于百度翻译 以下为原文 Address to write and 24 bits of data. My application did not explicitly erase the page, but it doesn't matter because it is already erased simply by programming the part. I have two applications. The first is the one I'm developing for a customer. The application will write to a page that is left unused due to a custom linker script. If the data is already written, the application will not try to write it again. Eventually, the bootloader will erase that page, which will cause the application to write the data the next time it starts. My second application is a simple example. The program does nothing except delay at startup for 100mS then writes to address 0x10000. Address 0x10000 was blank, the linker didn't put code there. But it erased the first page of flash. Yup, the FLASH_ERASE_CODE, FLASH_WRITE_ROW_CODE, and FLASH_WRITE_WORD_CODE defines appear to be wrong. The write word code was defined as the erase code, so when the write function is called, it erases the first page of flash because the instructions are wrong. I'm going to let Microchip handle it. I need to finish up SD card support. Hopefully I'll have that working by the end of today and then I'll get back to the bootloader. If Microchip hasn't gotten back to me with corrected assembly code then I'll write my own. |
|
|
|
|
|
这是我使用的PIC24FJGB1,GB4,GB6系列。我看到了我自己的旧评论。因此,PIC24FJGB1的WordPoxWord代码0x400完全改变了它的意思,以便删除新的PICS。您可以在这里确认PIC24FJ256GA705系列的新代码:HTTP:/WW1.MICCHIP.COM/DeLoSs/En/DeVICEDC/OC1010102B.PDF(表3.2)。为您的PIC擦除页面IST0x400
以上来自于百度翻译 以下为原文 This is what I use for the PIC24FJGB1, GB4, GB6 families. And I just see my own old comment here. // libpic30.h contains definitions for these constants, but is completely wrong and never updated for newer PIC24 #if defined __PIC24FJGB1_FAMILY__ #define _FLASH_ERASE_CODE 0x4042 #define _FLASH_WRITE_ROW_CODE 0x4001 #define _FLASH_WRITE_WORD_CODE 0x4003 #endif #if defined __PIC24FJGB4_FAMILY__ || defined __PIC24FJGB6_FAMILY__ #define _FLASH_ERASE_CODE 0x4003 #define _FLASH_WRITE_WORD_CODE 0x4001 #endif So the WRITE_WORD code 0x4003 for the PIC24FJGB1 has completely changed its meaning to ERASE for the newer PICs. You can confirm the newer codes for your PIC24FJ256GA705 FAMILY here: http://ww1.microchip.com/downloads/en/DeviceDoc/30010102b.pdf (Table 3.2) i.e. ERASE PAGE ist 0x4003 for your PIC |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5795 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 20:09 , Processed in 1.136911 second(s), Total 96, Slave 79 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
3535