ch32v003fun icon indicating copy to clipboard operation
ch32v003fun copied to clipboard

blink not working on WeAct Studio CH32X035F8U6 board

Open nanikjava opened this issue 4 months ago • 8 comments

Hi,

I've got this board and compiled ch32v003fun/examples_x035/blink/blink.c modified the code a bit like the following:

#include "ch32v003fun.h"
#include <stdio.h>

int main()
{
	SystemInit();

	funGpioInitAll();

	funPinMode( PB12, GPIO_CFGLR_OUT_10Mhz_PP );

	while(1)
	{
		funDigitalWrite( PB12, FUN_HIGH );	 // Turn on GPIO
		Delay_Ms( 1000 );
		funDigitalWrite( PB12, FUN_LOW );	 // Turn off GPIO
		Delay_Ms( 1000 );
	}
}

I've cross-compiled the toolchain on my Linux machine and was able to compile the sample code and got the following output:

riscv32-unknown-elf-gcc -E -P -x c -DTARGET_MCU=CH32X035 -DMCU_PACKAGE=1 -DTARGET_MCU_LD=4		 -DTARGET_MCU_MEMORY_SPLIT= ../../ch32v003fun//ch32v003fun.ld > ../../ch32v003fun//generated_CH32X035F8U6_.ld
riscv32-unknown-elf-gcc -o blink.elf ../../ch32v003fun//ch32v003fun.c blink.c   -g -Os -flto -ffunction-sections -fdata-sections -fmessage-length=0 -msmall-data-limit=8 -march=rv32imac -mabi=ilp32 -DCH32X03x=1 -static-libgcc -I/usr/include/newlib -I../../ch32v003fun//../extralibs -I../../ch32v003fun/ -nostdlib -I. -Wall  -Wl,--print-memory-usage -lgcc -T ../../ch32v003fun//generated_CH32X035F8U6_.ld -Wl,--gc-sections
Memory region         Used Size  Region Size  %age Used
           FLASH:         524 B        62 KB      0.83%
             RAM:           0 B        20 KB      0.00%
riscv32-unknown-elf-objdump -S blink.elf > blink.lst
riscv32-unknown-elf-objdump -t blink.elf > blink.map
riscv32-unknown-elf-objcopy -O binary blink.elf blink.bin
riscv32-unknown-elf-objcopy -O ihex blink.elf blink.hex
make -C ../../ch32v003fun//../minichlink all
make[1]: Entering directory '/home/nanik/Downloads/devboards/ch32v003fun/minichlink'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/nanik/Downloads/devboards/ch32v003fun/minichlink'
../../ch32v003fun//../minichlink/minichlink -w blink.bin flash -b
WARNING: You are not in the plugdev group, the canned udev rules will not work on your system.
Error: Could not initialize any supported programmers
Error: Could not initialize any supported programmers
make: *** [../../ch32v003fun/ch32v003fun.mk:241: cv_flash] Error 224

The changes made was the pin PB12 as per the schematic the LED is at PB12 (not sure if I did it right or wrong, appreciate any feedback) on the code.

I'm using the wchisp project to flash the board using the following command

wchisp  -v flash ./blink.elf -V

which I got the following response

12:28:45 [INFO] Opening USB device #0
12:28:45 [DEBUG] (1) wchisp::transport::usb: Found USB Device Bus 001 Device 085: ID 1a86:55e0
12:28:45 [DEBUG] (1) wchisp::transport: => a11200   00004d4355204953502026205743482e434e
12:28:45 [DEBUG] (1) wchisp::transport: <= a1000200 5e23
12:28:45 [DEBUG] (1) wchisp::transport: => a11200   00004d4355204953502026205743482e434e
12:28:45 [DEBUG] (1) wchisp::transport: <= a1000200 5e23
12:28:45 [DEBUG] (1) wchisp::flashing: found chip: CH32X035F8U6[0x5e23]
12:28:45 [DEBUG] (1) wchisp::transport: => a70200   1f00
12:28:45 [DEBUG] (1) wchisp::transport: <= a7001a00 1f00ff001fe000ff00ffffffffff00020600cdaba1716cbcdad9
12:28:45 [DEBUG] (1) wchisp::flashing: read_config: ff001fe000ff00ffffffffff00020600cdaba1716cbcdad9
12:28:45 [INFO] Chip: CH32X035F8U6[0x5e23] (Code Flash: 64KiB)
12:28:45 [INFO] Chip UID: CD-AB-A1-71-6C-BC-DA-D9
12:28:45 [INFO] BTVER(bootloader ver): 02.60
12:28:45 [DEBUG] (1) wchisp::transport: => a70200   1f00
12:28:45 [DEBUG] (1) wchisp::transport: <= a7001a00 1f00ff001fe000ff00ffffffffff00020600cdaba1716cbcdad9
12:28:45 [INFO] Current config registers: ff001fe000ff00ffffffffff00020600cdaba1716cbcdad9
RDPR_USER: 0xE01F00FF
  [7:0]   RDPR 0xFF (0b11111111)
    `- Protected
  [16:16] IWDG_SW 0x1 (0b1)
    `- IWDG enabled by the software, and disabled by hardware
  [17:17] STOP_RST 0x1 (0b1)
    `- Disable
  [18:18] STANDBY_RST 0x1 (0b1)
    `- Disable, entering standby-mode without RST
  [20:19] RST_MOD 0x3 (0b11)
    `- Disable RST alternative function, use PA21/PC3/PB7 as GPIO
DATA: 0xFF00FF00
  [7:0]   DATA0 0x0 (0b0)
  [23:16] DATA1 0x0 (0b0)
WRP: 0xFFFFFFFF
  `- Unprotected
12:28:45 [INFO] Read /home/nanik/Downloads/devboards/ch32v003fun/examples_x035/blink/blink.elf as ELF format
12:28:45 [INFO] Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
12:28:45 [DEBUG] (1) wchisp::format: Matching section: ".init" offset: 0x1000 size: 0xe0
12:28:45 [DEBUG] (1) wchisp::format: Matching section: ".text" offset: 0x10e0 size: 0x12c
12:28:45 [INFO] Section names: [".init", ".text"]
12:28:45 [DEBUG] (1) wchisp::format: found 1 sections
12:28:45 [INFO] Firmware size: 1024
12:28:45 [INFO] Erasing...
12:28:45 [WARN] erase_code: set min number of erased sectors to 8
12:28:45 [DEBUG] (1) wchisp::transport: => a40400   08000000
12:28:45 [DEBUG] (1) wchisp::transport: <= a4000200 0000
12:28:45 [INFO] Erased 8 code flash sectors
12:28:46 [INFO] Erase done
12:28:46 [INFO] Writing to code flash...
12:28:46 [DEBUG] (1) wchisp::transport: => a31e00   000000000000000000000000000000000000000000000000000000000000
12:28:46 [DEBUG] (1) wchisp::transport: <= a3000200 8600
12:28:46 [DEBUG] (1) wchisp::transport: => a53d00   000000005b0a65656b656565c303646565016465c365656565016465c365656565656565c301646565016465c365656565656565c301646565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 56/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   38000000cc01646565656565c301646565016465c301646565016465c301646565016465c301646565016465c301646565016465c301646565016465c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
███████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 112/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   700000008701646565016465c301646565016465c301646565016465c301646565016465c301646565016465c301646565016465c301646565016465c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 168/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   a80000004801646565016465c301646565016465c301646565016465c301646565016465c301646565016465c301646565016465c301646565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
███████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 224/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   e000000028f2646545f6e464b1723465457664e432f667e56d16c567f3c82716f527e5e885726065657660603330e81675305572c665457660408af2c6
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 280/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   18010000376545f6e0c08b64850633d06575a474c6862bd09b7660a5e3f2606545f6e0602e726365457663e32f06eda0657124f1027460f46086ffa03d
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
███████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 336/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   5001000060d29265856022fd00f662057f16f572f71665455564c552d467257922d263e5c3b0ea79a2d24267836c22fda6d272678352626d6546c762c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 392/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   88010000307662726dfda652c4fa65fda2d262652346c7625d766265cb46c5825de7e524d263a38c5252726783792ad263949a98d5f682b26479aa52d4
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
███████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 448/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   c0010000846425766222a57980600d52606575904ca403b0ea79a6d2553e65d2726425f64462a552926585f64563bd46cd62646984d3f0752268eb868d
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 504/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   f8010000ff639bedae6922d356752268eb862b633da8d26565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
██████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 560/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   300200005065656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 616/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   680200005b65656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 672/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   a00200005d65656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 728/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   d80200001665656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 784/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   100300004265656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 840/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   480300004965656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░ 896/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   800300002265656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░ 952/102412:28:46 [DEBUG] (1) wchisp::transport: => a53d00   b80300008465656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░ 1008/102412:28:46 [DEBUG] (1) wchisp::transport: => a51500   f00300006e65656565656565c365656565656565c3
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 1024/102412:28:46 [DEBUG] (1) wchisp::transport: => a50500   0004000086
12:28:46 [DEBUG] (1) wchisp::transport: <= a5000200 0000
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 1024/102412:28:46 [INFO] Code flash 1024 bytes written
12:28:47 [WARN] Skipping verify
12:28:47 [INFO] Now reset device and skip any communication errors
12:28:47 [DEBUG] (1) wchisp::transport: => a20100   01
12:28:47 [DEBUG] (1) wchisp::transport: <= a2000200 0000
12:28:47 [INFO] Device reset

The problem is the LED is not flashing as per what the code is doing

nanikjava avatar Oct 11 '24 12:10 nanikjava