3
\$\begingroup\$

We have a product using the PIC32MX795F512L out in the field that has firmware in both the boot and program sections.

The boot flash is write protected using the BWP bit 24 = 0 in DEVCFG0. The firmware is not Code Protected (CP bit 28 in DEVFG0). The program section is also unprotected and writable.

We find ourselves in a situation where we need to update the boot flash. Since these units are overseas, we have no physical access to them, thus we cannot hook up a laptop and Microchip programmer like the ICD3 or RealICE and reprogram them (which would give us access to both the boot and program areas0.

We are able to update the program section via a firmware update through our cellular modem.

Is there any way to programmatically set the BWP bit in DEVCFG0, so we can overwrite the boot flash with new code?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Answer based purely on the information provided in the Reference Manual. Contacting Microchip tech support would probably be a good idea.

Q1: Can BWP bit be reset?

No, since the configuration bits are stored in the BFM, which is write-protected. From the PIC32MX Reference manual, Section 32.2.1:

In the PIC32 device families, the Configuration Words select various device configurations, and are located in the last four Words (32-bit x 4 Words) of Boot Flash memory, DEVCFG0 to DEVCFG3.

Additionally, the DEVCFG0 word can only be programmed once. After that, an erase is required:

The Configuration Word, DEVCFG0, can only be programmed once before a page erase must be preformed. Each time the Boot Flash memory region is erased, the DEVCFG0<31> bit is automatically set to ‘0’, leaving only one additional programming operation available, DEVCFG0.

Q2: Can we write a program to erase the BFM and, therefore, "reset" BWP?

No. Flash cannot be erased if it's write-protected. From the reference manual Section 5.7:

A page erase performs an erase of a single page of either PFM or BFM. Refer to the specific device data sheet for the page size. The page to be erased is selected using the NVMADDR register.

A page of Flash can only be erased if its associated page write protection is not enabled.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I had read about the first part, re only being able to program DEVCFG0 once, but that seemed to not be useful since you can onl;y program 0's. And then re the second part, about erasing it back to 1, I didn't make the connection that the configuration bits were in the same section of flash so I couldn't modify them. \$\endgroup\$
    – tcrosley
    Aug 21, 2014 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.