Can not bootload with another microcontroller
Hi,
We are trying to flash the pico with an esp32s3 and a sd card.
The esp32 setup can copy the uf2 to a usb flash drive and the destination file matches the original.
When the pico is plugged in place of the flash drive, it enumerates. I can read a text file from it and copy up to 1036288 bytes worth of the uf2 to it. After this it fails with i/o error (errno=5).
The esp32 usb host stack does not trigger a single error.
Any ideas on what else I can try?
Thank you.
Is the esp32 trying to read-back or verify the data that was written? This sounds a little bit like https://www.raspberrypi.com/news/the-ventura-problem/ ?
Of course, if you're able to, using SWD might be more reliable than copying a UF2 over USB? :shrug:
Yes it seem to update the FAT while writing to the uf2 file.
...
I (12197) example: Read source 16384 bytes
I (12197) example: Write uf2 16384 bytes to 966656
I (12197) diskio_usb: Disk write sector: 2196 count: 8
I (12247) diskio_usb: Disk write sector: 2204 count: 8
I (12257) diskio_usb: Disk write sector: 2212 count: 8
I (12297) diskio_usb: Disk write sector: 2220 count: 8
I (12337) example: Read source 16384 bytes
I (12337) example: Write uf2 16384 bytes to 983040
I (12337) diskio_usb: Disk write sector: 2228 count: 8
I (12377) diskio_usb: Disk write sector: 2236 count: 8
I (12387) diskio_usb: Disk write sector: 2244 count: 8
I (12437) diskio_usb: Disk write sector: 2252 count: 8
I (12467) example: Read source 16384 bytes
I (12467) example: Write uf2 16384 bytes to 999424
I (12467) diskio_usb: Disk write sector: 2260 count: 8
I (12517) diskio_usb: Disk write sector: 2268 count: 8
I (12527) diskio_usb: Disk write sector: 2276 count: 8
I (12567) diskio_usb: Disk write sector: 2284 count: 8
I (12597) example: Read source 16384 bytes
I (12597) example: Write uf2 16384 bytes to 1015808
I (12597) diskio_usb: Disk write sector: 2292 count: 8
I (12647) diskio_usb: Disk write sector: 2300 count: 8
I (12657) diskio_usb: Disk write sector: 2308 count: 8
I (12707) diskio_usb: Disk write sector: 2316 count: 8
I (12737) example: Read source 16384 bytes
I (12737) example: Write uf2 16384 bytes to 1032192
I (12737) diskio_usb: Disk write sector: 2 count: 1
I (12747) diskio_usb: Disk read sector: 3 count: 1
I (12757) diskio_usb: Disk write sector: 3 count: 1
I (12757) diskio_usb: Disk read sector: 2 count: 1
I (12767) diskio_usb: Disk write sector: 2324 count: 8
I (12817) diskio_usb: Disk write sector: 2 count: 1
I (12817) diskio_usb: Disk read sector: 3 count: 1
E (12817) example: Read and write do not match: 16384; 4096
I (12847) example: Read source 16384 bytes
I (12847) example: Write uf2 16384 bytes to -1
I (12847) example: errno: 5
E (12847) example: Read and write do not match: 16384; 0
I (12877) example: Read source 16384 bytes
I (12877) example: Write uf2 16384 bytes to -1
I (12877) example: errno: 5
E (12877) example: Read and write do not match: 16384; 0
I (12907) example: Read source 16384 bytes
I (12907) example: Write uf2 16384 bytes to -1
I (12907) example: errno: 5
E (12907) example: Read and write do not match: 16384; 0
I (12937) example: Read source 16384 bytes
I (12937) example: Write uf2 16384 bytes to -1
I (12937) example: errno: 5
E (12947) example: Read and write do not match: 16384; 0
I (12967) example: Read source 16384 bytes
I (12977) example: Write uf2 16384 bytes to -1
I (12977) example: errno: 5
E (12977) example: Read and write do not match: 16384; 0
I (13007) example: Read source 16384 bytes
I (13007) example: Write uf2 16384 bytes to -1
I (13007) example: errno: 5
E (13007) example: Read and write do not match: 16384; 0
I (13037) example: Read source 16384 bytes
I (13037) example: Write uf2 16384 bytes to -1
I (13037) example: errno: 5
E (13037) example: Read and write do not match: 16384; 0
I (13067) example: Read source 16384 bytes
I (13067) example: Write uf2 16384 bytes to -1
I (13067) example: errno: 5
E (13067) example: Read and write do not match: 16384; 0
I (13097) example: Read source 16384 bytes
I (13097) example: Write uf2 16384 bytes to -1
I (13097) example: errno: 5
E (13097) example: Read and write do not match: 16384; 0
I (13127) example: Read source 16384 bytes
I (13127) example: Write uf2 16384 bytes to -1
I (13127) example: errno: 5
E (13127) example: Read and write do not match: 16384; 0
I (13157) example: Read source 16384 bytes
I (13157) example: Write uf2 16384 bytes to -1
I (13157) example: errno: 5
E (13167) example: Read and write do not match: 16384; 0
I (13197) example: Read source 16384 bytes
I (13197) example: Write uf2 16384 bytes to -1
I (13197) example: errno: 5
E (13197) example: Read and write do not match: 16384; 0
I (13227) example: Read source 16384 bytes
I (13227) example: Write uf2 16384 bytes to -1
I (13227) example: errno: 5
E (13227) example: Read and write do not match: 16384; 0
I (13257) example: Read source 16384 bytes
I (13257) example: Write uf2 16384 bytes to -1
I (13257) example: errno: 5
E (13257) example: Read and write do not match: 16384; 0
I (13287) example: Read source 16384 bytes
I (13287) example: Write uf2 16384 bytes to -1
I (13287) example: errno: 5
E (13287) example: Read and write do not match: 16384; 0
I (13317) example: Read source 16384 bytes
I (13317) example: Write uf2 16384 bytes to -1
I (13317) example: errno: 5
E (13317) example: Read and write do not match: 16384; 0
I (13347) example: Read source 16384 bytes
I (13347) example: Write uf2 16384 bytes to -1
I (13347) example: errno: 5
E (13357) example: Read and write do not match: 16384; 0
I (13377) example: Read source 16384 bytes
I (13377) example: Write uf2 16384 bytes to -1
I (13377) example: errno: 5
E (13387) example: Read and write do not match: 16384; 0
I (13417) example: Read source 16384 bytes
I (13417) example: Write uf2 16384 bytes to -1
I (13417) example: errno: 5
E (13417) example: Read and write do not match: 16384; 0
I (13427) example: Read source 7168 bytes
I (13427) example: Write uf2 7168 bytes to -1
I (13427) example: errno: 5
E (13437) example: Read and write do not match: 7168; 0
I (13437) diskio_usb: Disk read sector: 260 count: 1
I (13447) diskio_usb: Disk write sector: 260 count: 1
I (13457) example: Read: 1367040; Written 1036288
I (13477) example: Done
I (12817) diskio_usb: Disk write sector: 2 count: 1
I (12817) diskio_usb: Disk read sector: 3 count: 1
E (12817) example: Read and write do not match: 16384; 4096
Looks like you need to tell diskio_usb to not try reading from the virtual RP2040 USB drive, since the data written there can't actually be read back.
So, I've cloned the fist 292 (all before the file data area) sectors of the pico drive and cached it in the firmware.
Reworked the low level media read/write functions, so the reads are from the cache and writes below sector 259 (root start) are ignored.
All physical transfers are logged.
In case I am not transferring sectors outside the file write stream, is there any other reason for the pico to complain about it?
Thank you.
I (4209) diskio_usb: Cached disk read sector: 0 count: 1
I (4209) diskio_usb: Cached disk read sector: 1 count: 1
I (4229) diskio_usb: Cached disk read sector: 260 count: 1
I (4329) example: Read source 65536 bytes
I (4329) example: Write uf2 65536 bytes to offset 0
I (4329) diskio_usb: Physical disk write sector: 260 count: 1
I (4329) diskio_usb: Cached disk read sector: 2 count: 1
I (4339) diskio_usb: Physical disk write sector: 308 count: 8
I (4389) diskio_usb: Physical disk write sector: 316 count: 8
I (4399) diskio_usb: Physical disk write sector: 324 count: 8
I (4439) diskio_usb: Physical disk write sector: 332 count: 8
I (4449) diskio_usb: Physical disk write sector: 340 count: 8
I (4499) diskio_usb: Physical disk write sector: 348 count: 8
I (4509) diskio_usb: Physical disk write sector: 356 count: 8
I (4549) diskio_usb: Physical disk write sector: 364 count: 8
I (4559) diskio_usb: Physical disk write sector: 372 count: 8
I (4619) diskio_usb: Physical disk write sector: 380 count: 8
I (4629) diskio_usb: Physical disk write sector: 388 count: 8
I (4679) diskio_usb: Physical disk write sector: 396 count: 8
I (4689) diskio_usb: Physical disk write sector: 404 count: 8
I (4739) diskio_usb: Physical disk write sector: 412 count: 8
I (4749) diskio_usb: Physical disk write sector: 420 count: 8
I (4799) diskio_usb: Physical disk write sector: 428 count: 8
I (4829) diskio_usb: Physical write sector: 444 count: 8
I (4839) diskio_usb: Physical write sector: 452 count: 8
I (4889) diskio_usb: Physical write sector: 460 count: 8
I (4899) diskio_usb: Physical write sector: 468 count: 8
I (4939) diskio_usb: Physical write sector: 476 count: 8
I (4949) diskio_usb: Physical write sector: 484 count: 8
I (4989) diskio_usb: Physical write sector: 492 count: 8
I (5009) diskio_usb: Physical write sector: 500 count: 8
I (5049) diskio_usb: Physical write sector: 508 count: 8
I (5059) diskio_usb: Physical write sector: 516 count: 8
I (5109) diskio_usb: Physical write sector: 524 count: 8
I (5119) diskio_usb: Physical write sector: 532 count: 8
I (5169) diskio_usb: Physical write sector: 540 count: 8
I (5179) diskio_usb: Physical write sector: 548 count: 8
I (5229) diskio_usb: Physical write sector: 556 count: 8
I (5329) example: Read source 65536 bytes
I (5329) example: Write uf2 65536 bytes to offset 131072
I (5329) diskio_usb: Physical write sector: 564 count: 8
I (5389) diskio_usb: Physical write sector: 572 count: 8
I (5399) diskio_usb: Physical write sector: 580 count: 8
I (5439) diskio_usb: Physical write sector: 588 count: 8
I (5449) diskio_usb: Physical write sector: 596 count: 8
I (5499) diskio_usb: Physical write sector: 604 count: 8
I (5509) diskio_usb: Physical write sector: 612 count: 8
I (5549) diskio_usb: Physical write sector: 620 count: 8
I (5559) diskio_usb: Physical write sector: 628 count: 8
I (5599) diskio_usb: Physical write sector: 636 count: 8
I (5609) diskio_usb: Physical write sector: 644 count: 8
I (5669) diskio_usb: Physical write sector: 652 count: 8
I (5679) diskio_usb: Physical write sector: 660 count: 8
I (5729) diskio_usb: Physical write sector: 668 count: 8
I (5739) diskio_usb: Physical write sector: 676 count: 8
I (5779) diskio_usb: Physical write sector: 684 count: 8
I (5879) example: Read source 65536 bytes
I (5879) example: Write uf2 65536 bytes to offset 196608
I (5879) diskio_usb: Physical write sector: 692 count: 8
I (5929) diskio_usb: Physical write sector: 700 count: 8
I (5939) diskio_usb: Physical write sector: 708 count: 8
I (5979) diskio_usb: Physical write sector: 716 count: 8
I (5989) diskio_usb: Physical write sector: 724 count: 8
I (6029) diskio_usb: Physical write sector: 732 count: 8
I (6039) diskio_usb: Physical write sector: 740 count: 8
I (6079) diskio_usb: Physical write sector: 748 count: 8
I (6089) diskio_usb: Physical write sector: 756 count: 8
I (6139) diskio_usb: Physical write sector: 764 count: 8
I (6149) diskio_usb: Physical write sector: 772 count: 8
I (6199) diskio_usb: Physical write sector: 780 count: 8
I (6209) diskio_usb: Physical write sector: 788 count: 8
I (6249) diskio_usb: Physical write sector: 796 count: 8
I (6259) diskio_usb: Physical write sector: 804 count: 8
I (6309) diskio_usb: Physical write sector: 812 count: 8
...
...
...
I (12449) example: Read source 65536 bytes
I (12449) example: Write uf2 65536 bytes to offset 983040
I (12449) diskio_usb: Physical disk write sector: 2228 count: 8
I (12499) diskio_usb: Physical disk write sector: 2236 count: 8
I (12509) diskio_usb: Physical disk write sector: 2244 count: 8
I (12549) diskio_usb: Physical disk write sector: 2252 count: 8
I (12559) diskio_usb: Physical disk write sector: 2260 count: 8
I (12599) diskio_usb: Physical disk write sector: 2268 count: 8
I (12609) diskio_usb: Physical disk write sector: 2276 count: 8
I (12649) diskio_usb: Physical disk write sector: 2284 count: 8
I (12659) diskio_usb: Physical disk write sector: 2292 count: 8
I (12709) diskio_usb: Physical disk write sector: 2300 count: 8
I (12719) diskio_usb: Physical disk write sector: 2308 count: 8
I (12769) diskio_usb: Physical disk write sector: 2316 count: 8
I (12779) diskio_usb: Ignored disk write sector: 2 count: 1
I (12779) diskio_usb: Ignored disk write sector: 131 count: 1
I (12779) diskio_usb: Cached disk read sector: 3 count: 1
I (12789) diskio_usb: Ignored disk write sector: 3 count: 1
I (12789) diskio_usb: Ignored disk write sector: 132 count: 1
I (12799) diskio_usb: Cached disk read sector: 2 count: 1
I (12799) diskio_usb: Physical disk write sector: 2324 count: 8
I (12859) diskio_usb: Ignored disk write sector: 2 count: 1
I (12859) diskio_usb: Ignored disk write sector: 131 count: 1
I (12859) diskio_usb: Cached disk read sector: 3 count: 1
E (12869) example: Read and write do not match: 65536; 53248
I (12969) example: Read source 65536 bytes
I (12969) example: Write uf2 65536 bytes to offset -1
I (12969) example: errno: 5
E (12969) example: Read and write do not match: 65536; 0
I (13069) example: Read source 65536 bytes
I (13069) example: Write uf2 65536 bytes to offset -1
I (13069) example: errno: 5
E (13069) example: Read and write do not match: 65536; 0
I (13169) example: Read source 65536 bytes
I (13169) example: Write uf2 65536 bytes to offset -1
I (13169) example: errno: 5
E (13179) example: Read and write do not match: 65536; 0
I (13269) example: Read source 65536 bytes
I (13269) example: Write uf2 65536 bytes to offset -1
I (13269) example: errno: 5
E (13279) example: Read and write do not match: 65536; 0
I (13359) example: Read source 56320 bytes
I (13359) example: Write uf2 56320 bytes to offset -1
I (13359) example: errno: 5
E (13359) example: Read and write do not match: 56320; 0
I (13369) diskio_usb: Cached disk read sector: 260 count: 1
I (13379) diskio_usb: Physical disk write sector: 260 count: 1
I (13379) example: Total: 1367040; 1036288
I (13389) gpio: GPIO[8]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (13399) gpio: GPIO[36]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (13409) example: Done