My interest is in using JTAG to read and more importantly to write NAND flash. This could be a way of patching the NAND image (which I now do via U-Boot) or of installing a Kyu image into a NAND partition (which could also be done by way of U-Boot and tftp).
Here is the new pinout:
STM32 JTAG PA7 TDI PA6 TDO PA5 TCK PA3 TMS PA4 TRST PA2 SRSTThe original (old and obsolete) pinout used PA0 through PA5, as per the CNX article above.
All 3 "bin" files are the same size (9224 bytes) and after I clone the repository and look at the Makefile, I see the only difference is the link address, which is as follows:
dirtyjtag.bluepill.loader2k.bin -- 0x08002000 dirtyjtag.bluepill.loader4k.bin -- 0x08004000 dirtyjtag.bluepill.noloader.bin -- 0x08000000So, it is all a question of leaving room at the start of rom for a serial bootloader. I will just use an ST-Link dongle to flash my blue pill, so I don't need to worry about a serial bootloader and should just use the "noloader" bin file.
Now on fedora (fedora 39) at the time of this writing), I need:
dnf install stlinkNow, dig up a ST-Link v2 dongle and a "blue pill" board. My ST-link has a 4 conductor cable already carefully set up to attach to a "blue pill" otherwise we would have to fuss with that.
I plug in the ST-link and the pill starts a blink demo that I installed once to test all my boards. The linux logs show this:
Apr 24 21:29:23 trona kernel: usb 4-1.2: new full-speed USB device number 104 using ehci-pci Apr 24 21:29:23 trona kernel: usb 4-1.2: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00 Apr 24 21:29:23 trona kernel: usb 4-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 Apr 24 21:29:23 trona kernel: usb 4-1.2: Product: STM32 STLink Apr 24 21:29:23 trona kernel: usb 4-1.2: Manufacturer: STMicroelectronicsThen we do it (I put the command in a Makefile).
make burn st-flash write dirtyjtag.bluepill.noloader.bin 0x08000000 st-flash 1.8.0 2024-04-24T21:34:06 INFO common.c: STM32F1xx_MD: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages. file dirtyjtag.bluepill.noloader.bin md5 checksum: dc87643c89d1b379476ddda919fbc853, stlink checksum: 0x000db627 2024-04-24T21:34:06 INFO common_flash.c: Attempting to write 9224 (0x2408) bytes to stm32 address: 134217728 (0x8000000) -> Flash page at 0x8002400 erased (size: 0x400) 2024-04-24T21:34:06 INFO flash_loader.c: Starting Flash write for VL/F0/F3/F1_XL 2024-04-24T21:34:06 INFO flash_loader.c: Successfully loaded flash loader in sram 2024-04-24T21:34:06 INFO flash_loader.c: Clear DFSR 10/10 pages written 2024-04-24T21:34:07 INFO common_flash.c: Starting verification of write complete 2024-04-24T21:34:07 INFO common_flash.c: Flash written and verified! jolly good!Now I find a micro-USB cable and plug it in. The linux logs show:
Apr 24 21:36:19 trona kernel: usb 4-1.2: new full-speed USB device number 105 using ehci-pci Apr 24 21:36:19 trona kernel: usb 4-1.2: New USB device found, idVendor=1209, idProduct=c0ca, bcdDevice= 2.00 Apr 24 21:36:19 trona kernel: usb 4-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 Apr 24 21:36:19 trona kernel: usb 4-1.2: Product: DirtyJTAG Apr 24 21:36:19 trona kernel: usb 4-1.2: Manufacturer: Jean THOMAS Apr 24 21:36:19 trona kernel: usb 4-1.2: SerialNumber: 56FF6C065186525453470487I am particularly satisfied to see that Serial Number! Looks like a success. Also urjtag accepts it as a cable. We cannot go farther without soldering some wires.
Tom's Computer Info / [email protected]