Skip to content
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 you please help me get blinky example to work? #1

Open
mejobloggs opened this issue May 14, 2023 · 2 comments
Open

Can you please help me get blinky example to work? #1

mejobloggs opened this issue May 14, 2023 · 2 comments

Comments

@mejobloggs
Copy link

Hello Slappy, may I have some help please? I am trying to learn

I flash blinky, but I see no light. See my cargo run output below

Also, is it normal I need to pull usb out, hold down bootloader button, and plug usb in again to flash? And if I wait too long I cant flash and have to pull usb out again. Is there easier way?

Thank you


❯ cargo run --example blinky
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `wchisp flash target\riscv32imac-unknown-none-elf\debug\examples\blinky`
06:16:47 [INFO] Chip: CH582[0x8216] (Code Flash: 448KiB, Data EEPROM: 32KiB)
06:16:47 [INFO] Chip UID: 24-7F-A9-26-3B-38-08-DE
06:16:47 [INFO] BTVER(bootloader ver): 02.40
06:16:47 [INFO] Current config registers: ffffffffffffffff4f3f0f4d
RESERVED: 0xFFFFFFFF
WPROTECT: 0xFFFFFFFF
  [0:0]   NO_KEY_SERIAL_DOWNLOAD 0x1 (0b1)
    `- Enable
  [1:1]   DOWNLOAD_CFG 0x1 (0b1)
    `- PB22(Default set)
USER_CFG: 0x4D0F3F4F
  [2:0]   RESERVED 0x7 (0b111)
    `- Changed
  [3:3]   CFG_RESET_EN 0x1 (0b1)
    `- Enable
  [4:4]   CFG_DEBUG_EN 0x0 (0b0)
    `- Disable
  [5:5]   RESERVED 0x0 (0b0)
  [6:6]   CFG_BOOT_EN 0x1 (0b1)
    `- Enable
  [7:7]   CFG_ROM_READ 0x0 (0b0)
    `- Disable the programmer to read out, and keep the program secret
  [27:8]  RESERVED 0xD0F3F (0b11010000111100111111)
    `- Changed
  [31:28] VALID_SIG 0x4 (0b100)
    `- Valid
06:16:47 [INFO] Read target\riscv32imac-unknown-none-elf\debug\examples\blinky as ELF format
06:16:47 [INFO] Found loadable segment, physical address: 0x08000000, virtual address: 0x08000000, flags: 0x5
06:16:47 [INFO] Section names: [".text"]
06:16:47 [INFO] Found loadable segment, physical address: 0x080011e0, virtual address: 0x080011e0, flags: 0x4
06:16:47 [INFO] Section names: [".rodata"]
06:16:47 [INFO] Firmware size: 6144
06:16:47 [INFO] Erasing...
06:16:47 [WARN] erase_code: set min number of erased sectors to 8
06:16:47 [INFO] Erased 8 code flash sectors
06:16:48 [INFO] Erase done
06:16:48 [INFO] Writing to code flash...
███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 6144/614406:16:50 [INFO] Code flash 6144 bytes written
06:16:50 [INFO] Verifying...
███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 6144/614406:16:52 [INFO] Verify OK
06:16:52 [INFO] Now reset device and skip any communication errors
06:16:52 [INFO] Device reset
@Slappy2022
Copy link
Owner

You could also try the uart example and see if anything is landing on console. Your logs suggest the device flashed successfully. Perhaps your led is on a different pin? Can you link to the board you used? Were you able to flash in any of the

Here's the dev board I used:
https://www.amazon.com/gp/product/B0BJZCLFKH
As far as I know it's identical in function to the "official" wch dev board.

The procedure you give to flash the board sounds correct to me. Personally, I keep PB22 grounded and powercycle before each flashing, but that should be equivalent to your procedure. Have you tested your procedure on any of the code from the "official" repo? https://github.com/openwch/ch583

@mejobloggs
Copy link
Author

mejobloggs commented May 16, 2023

I have WeAct CH582F from https://www.aliexpress.com/item/1005004784988010.html

I found the WeAct blinky example:

https://github.com/WeActStudio/WeActStudio.WCH-BLE-Core/blob/master/Examples/CH582/template/src/Main.c

In board.h they have

void board_led_toggle(void)
{
    GPIOA_InverseBits(GPIO_Pin_8);
}

I use wchisp to flash https://github.com/WeActStudio/WeActStudio.WCH-BLE-Core/blob/master/Examples/CH582/template/obj/template.hex and now led blinking. Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants