---

** [tickets:#296] mips_m4k fast programming only writes first 128 bytes of 512 
blocks**

**Status:** new
**Milestone:** 0.10.0
**Labels:** bug mips m4k fast-programming 
**Created:** Mon Mar 08, 2021 07:45 AM UTC by Asger Gitz-Johansen
**Last Updated:** Mon Mar 08, 2021 07:45 AM UTC
**Owner:** nobody
**Attachments:**

- 
[program_flash_to_write_to_chip.hex](https://sourceforge.net/p/openocd/tickets/296/attachment/program_flash_to_write_to_chip.hex)
 (1.4 MB; application/octet-stream)
- 
[program_flash_written_to_chip.hex](https://sourceforge.net/p/openocd/tickets/296/attachment/program_flash_written_to_chip.hex)
 (1.4 MB; application/octet-stream)


# Problem With mips_m4k.c 's Fast Programming
I have been having the same journey as [this 
guy](https://hackaday.io/project/6450-operation-learn-the-mips-pic32mx1xx2xx370)
 did back in 2015/2016. The mips_m4k.c target is faulty in it's _fast 
programming_ part. The condition that enables the _fast programming_ routine is 
clearly errornious, forgetting to compare the `size - 1`. Patching this is 
fairly [straight 
forward](https://hackaday.io/project/6450-operation-learn-the-mips-pic32mx1xx2xx370/log/20840-wherein-we-discover-with-some-amount-of-certainty).

However, with the condition is patched, there is another problem exposed: 

## Fast Programming only writes 128 bytes
See attachments to see exactly what I mean. The 
`program_flash_to_write_to_chip.hex` is what we want to write to the chip and 
`program_flash_written_to_chip.hex` is a flash dump from after trying to write.

As seen, byte `0x7F (128 bytes)` is the last byte written in the 512 byte sized 
block. After that, the next 512 bytes are attempted to be written, but only the 
first 128 bytes are written. This smells like a hardcoded or math problem in 
the fast programming routine.

### Hardware I Use
 - Programmer: Raspberry Pi 3B+
 - Target Chip: 
[PIC32MX570F512L](https://ww1.microchip.com/downloads/en/DeviceDoc/PIC32MX1XX2XX5XX%2064100-PIN_Family_60001290F.pdf)
 -  Board: [Explorer 
16/32](https://www.microchip.com/DevelopmentTools/ProductDetails/dm240001-2) 
(Only used to host the chip)

### JTAG Connections

Please consult the chart below. Note that the raspberry pi numbers are the pin 
numbers. Not the GPIO numbers. The Board pin numbers refer to the [Explorer 
16/32](https://ww1.microchip.com/downloads/en/DeviceDoc/Explorer_16_32_Schematics_R6_3.pdf)
 board [PIM 
mapping](https://ww1.microchip.com/downloads/en/DeviceDoc/50002292A.pdf) pin 
numbers.

| **BoardPin#** | **JTAGPinName** | **RPiPIN#** | **RPiPIN#** | **JTAGPinName** 
| **BoardPin#** |
|---------------|-----------------|--------------|-------------|-----------------|---------------|
|               |                 |              | PIN 18      | SRST           
 | MCLR          |
| P60           | TDI             | PIN 19       | PIN 20      | GND            
 | GND           |
| P61           | TDO             | PIN 21       | PIN 22      | TMS            
 | P17           |
| P38           | TCK             | PIN 23       | PIN 24      | **Not 
Connected**   |               |




---

Sent from sourceforge.net because [email protected] is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to