Closed zoobab closed 1 year ago
I don't have any example, and I don't own a board with that chip.
However I was able to build a firmware from that git repo by using the toolchain at https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/tag/v12.2.0-3, fixing the few case sensitive includes and changing the arch from rv32imac to rv32imac_zicsr.
I got one board, with an LED on PB4. Using the repo and toolchain above-mentionned, replace Main.cpp with:
typedef volatile unsigned long *PUINT32V;
#define R32_PB_DIR (*((PUINT32V)0x400010C0)) // RW, GPIO PB I/O direction: 0=in, 1=out
#define R32_PB_OUT (*((PUINT32V)0x400010C8)) // RW, GPIO PB output
int main(void)
{
const unsigned int pin = (1<<4); /* pin 4 */
int i;
R32_PB_DIR |= pin; /* PB4 gpio direction out */
// Blink led at about 1Hz
while (1) {
for (i = 0; i < 50000; i++)
R32_PB_OUT |= pin; /* on */
for (i = 0; i < 50000; i++)
R32_PB_OUT &= ~pin; /* off */
}
}
Resulting binary is about 2KiB.
Hi,
Thanks for your flashing software, much simpler and better in C then the other tool in Rust.
I got a WeAct CH582F board, I managed to dump the firmware to a file.
I am now hunting for a simple Makefile and GCC toolchain to make a Blink program without all the WCH fluf, do you have a link to a good example?
I tried this repo https://github.com/dreamcmi/CH582-CMake yesterday with a riscv-none toolchain in Alpine 3.17, but got some headers errors.
Keep up the good work!