-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can support ST-Link V2 to download PY32F002A #6
Comments
Stlink firmware is locked to stm mcus - so, no. I think some older versions might be unlocked, but i dont know which, or if they'd be compatible. Daplink programmers are cheap, or you could build one yourself. I found that 'WCHLink' products DON'T work, and also that the raspberry pico pico probe doesn't work either. And my clone jlink doesnt work. But DAPLink works great. |
Yes, but only if you use Keil MDK. This repository is for GNU GCC toolchain(mostly for Linux users) so most of content here might not help. Keil MDK is a commercial software, you can install their community edition After Keil MDK is installed, you need to install the DFP pack, which you can download from Puya PY32F0 product page, the download link. Then you can use any of JLink/STLink/DAPLink to flash/debug your PY32F002A. For more details you can read the manuals in that pack
|
Have you tried the cheapest JLink OB? It works great too. |
These adapters do NOT work (for me). I have not spent much time troubleshooting them though; it may be possible to get them working. 'pyocd list' detects them, at least: This one DOES work: I would note that the one which does work appears to have a genuine STM32 device on it. All the others use WCH chips of varying types. |
Thanks for the links. The JLink OB I am using looks like this one, The DAPLink I am using is actually an AIR32F103 board(link) with DAPLink firmware (link), they just released the source code. This is not a genuine STM32, but it works 😉 |
there might be something fishy with my setup. I was playing around with some of the non-working probes, and while they all show up when I do a 'pyocd list,' none of them (save for one) work. They all generate varying errors with pyocd, and likewise generate unpredictable results with 'openocd -f cmsis-dap.cfg' The closest to a working probe is this one I built according to https://github.com/wagiminator/CH552-picoDAP - it erases the py32 just fine, but it times out when trying to write a firmware. In any case, I'm just glad to have one probe that works. Otherwise, I suspect some sort of USB timing issues. |
I spent some time documenting my results with a handful of different probes (and probe firmwares), and opened an issue with pyOCD. |
Awesome! Thank you for spending so much time investigating this issue. |
Just dropping a quick note: I couldn't get my J-Link to talk to PY32 chips - this was my first time using a J-Link. I also ran into some of the issues as noted by @prosper00. What worked for me: Use https://github.com/RadioOperator/STM32F103C8T6_CMSIS-DAP_SWO along with a cheap, easily available STM32 BluePill board. This firmware and hardware combination works with pyOCD very well without any problems. Also, https://daplink.io/ looked promising but it just wouldn't work on the STM32 BluePill board. I can open a PR to document my working programming setup. |
I did try a bluepill, with this firmware: https://github.com/devanlai/dap42 - I also flashed it onto an old stlink clone (which, incidentally, make great little usb dev boards cheap). Neither worked with pyocd with any target board. They were able to flash an stm32 target from openocd though. I've been trying to put together a target .cfg file for the py32 and openocd, with (very) limited success so far |
Yep - https://github.com/devanlai/dap42 didn't work me as well. https://github.com/RadioOperator/STM32F103C8T6_CMSIS-DAP_SWO works like a champ on the BluePill board. |
oh yeah - the RadioOperator version works for me in pyocd with the PY32 too. Ironically, I used the dap42 programmer with openocd to flash it to the bluepill... Tomorrow I'll flash it to an stlink and put it in my bin of dongles. Makes me really wonder what's up with pyocd, and want to double down on getting openocd up and running. Especially as openocd seems to be about 40 to 50 times faster than pyocd |
I have a very hacky pyOCD patch to make dap42 work with PY32. I just ignore some ACK related errors in pyOCD... |
Can confirm - the linked JLinkOB clone works for me. I also bought a genuine JLink Edu. It works too. |
Something I just discovered: programming works better at 3V3 Vcc. At least some of the probes that weren't working for me actually DO work, but only when running the PY32 at 3.3V. And all probes seem to work with more stability and reliability at 3.3V |
Nice detective work 👍 This may be because the probes themselves are 3V3 devices? |
That's is good to know. I rarely run py32 under 5V, so I didn't notice the difference. |
For me picoprobe works out of the box, for both PyOCD and my ugly OpenOCD fork. This is probably the cheapest way to flash and debug puya. My boards are powered from 3,3V though. If you powered your board from 1,8V and used 3,3V probe you violated absolute maximum rating of VCC+0.3V for pins, specified in datasheet. |
I'd be curious to see your openocd fork. I got as far as trying to create a flash routine in src/flash/nor/ ... never did get it to work. Getting it to connect and debug a running program, yes, but I gave up on trying to get flash working. In retrospect, yeah, using a 3.3V probe with 3.3V I/O was never going to work well, and probably risked damaging the probe too. |
I think i managed to write to the PY32F002 with a CMSIS_DAP made of a CH552. The cheapest CMSIS_DAP i think? This is the firmware for the CMSIS_DAP based on the CH552: |
I flashed the blink a led app but it doesn't flash the led |
Now it's working. My bad... I modify the Make File with the wrong parameters. I can confirm that you can flash the PY32F002 with a CH55x based CMSIS_DAP. |
If anyone is interested on the Design and gerber files to make a simple board for the PY32F002 and a cheap board based on the CH552 I can put the files here. |
|
have all file on github ? |
Are you blind?😄 Files are in the link! |
Did I understand correctly, this makefile will not work under Windows? |
You need something like mingw64 to run make under windows. |
Thanks for answer. Im try it. GNU make output: |
Download Arm GCC toolchain from https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads and extract it to /opt, Then in MSYS2 console # check version
ls /opt/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/bin/arm-none-eabi-gcc
/opt/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/bin/arm-none-eabi-gcc --version
arm-none-eabi-gcc.exe (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.1 20231009
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# unzip the code
unzip py32f0-template-main.zip
cd py32f0-template-main/
# install nano editor
pacman -S nano
# edit Makefile
nano Makefile Update the toolchain path in Makefile
Then make clean and make, the console output iosetting@a02-NC01 MSYS ~/py32f0-template-main
$ make clean
rm -rf ./Build/*
iosetting@a02-NC01 MSYS ~/py32f0-template-main
$ make
CC User/main.c
CC User/py32f0xx_hal_msp.c
CC User/py32f0xx_it.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_adc.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_adc_ex.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_comp.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_cortex.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_crc.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_dma.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_exti.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_flash.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_gpio.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_i2c.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_irda.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_iwdg.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_led.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_lptim.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_pwr.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_rcc.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_rcc_ex.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_rtc.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_rtc_ex.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_spi.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_tim.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_tim_ex.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_uart.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_usart.c
CC Libraries/PY32F0xx_HAL_Driver/Src/py32f0xx_hal_wwdg.c
CC Libraries/PY32F0xx_HAL_BSP/Src/py32f0xx_bsp_clock.c
CC Libraries/PY32F0xx_HAL_BSP/Src/py32f0xx_bsp_led.c
CC Libraries/PY32F0xx_HAL_BSP/Src/py32f0xx_bsp_printf.c
CC Libraries/CMSIS/Device/PY32F0xx/Source/system_py32f0xx.c
AS Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f030.s
LD Libraries/LDScripts/py32f030x8.ld -> Build/app.elf
Memory region Used Size Region Size %age Used
RAM: 2280 B 8 KB 27.83%
FLASH: 7808 B 64 KB 11.91%
OBJCP BIN Build/app.bin
OBJCP HEX Build/app.hex
iosetting@a02-NC01 MSYS ~/py32f0-template-main |
Thanks for Help!!! My setup - win10, STlink v2 (clone) converted to JLink, processor from disposable vape. |
I just googled to check what is "disposable vape" and why there is a processor in it, very interesting, I didn't know this kind of e-cig before. |
https://github.com/raspberrypi/debugprobe works really well with pyOCD and is also well maintained - highly recommended! |
Can support ST-Link V2 to download F200A
how to setup on windows ?
The text was updated successfully, but these errors were encountered: