aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.org6
-rw-r--r--src/boot.S11
-rwxr-xr-xsrc/main.rs28
3 files changed, 19 insertions, 26 deletions
diff --git a/README.org b/README.org
index 03c8939..1fd9975 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-looks like the start board is a gd32vf103cbt from the tiny print silk-screened on the chip.
+looks like the start board is a gd32vf103cbt from the tiny print silk-screened on the chip. [[https://www.tme.com/us/en-us/details/gd32vf103c-start/development-kits-others/gigadevice/][TME]] says it's a gd32vf103d6t6
which means it has 128k flash and 32k sram and 37(!) gpio pins
@@ -13,3 +13,7 @@ interrupt vector table is 4096 words starting from the start of flash (~mtvt~ re
according to the user manual (pg 51), at least when waking up, the system boots from ~0x0000_0000~ (which is an alias to the start of the main flash, iirc)
usb is 2.0 full-speed (12Mbps)
+
+* USART
+On [[https://github.com/tyustli/rt-thread/tree/master/bsp/gd32vf103v-eval][github]] it says that ~uart0~ tx/rx is gpio 9/10 — but that's for the eval board.
+See the [[https://github.com/riscv-mcu/GD32VF103_Firmware_Library/tree/master/Examples/USART/Printf][risc-v repository]] for a printf example.
diff --git a/src/boot.S b/src/boot.S
new file mode 100644
index 0000000..d31e5fe
--- /dev/null
+++ b/src/boot.S
@@ -0,0 +1,11 @@
+ .global _start
+ .section .text.init
+_start:
+ .option push
+ .option norelax
+ la gp, __global_pointer$
+ .option pop
+ la sp, _stack_top
+
+ csrr a0, mhartid
+ tail main
diff --git a/src/main.rs b/src/main.rs
index c0d41d3..8d95d00 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,11 @@
-#![feature(naked_functions)]
-
#![no_std]
#![no_main]
-use core::arch::asm;
+use core::arch::global_asm;
use gd32vf103_pac::Peripherals;
+global_asm!(include_str!("boot.S"));
+
#[no_mangle]
fn main(_hartid: usize) -> ! {
// let peripherals = Peripherals::take().unwrap();
@@ -49,28 +49,6 @@ fn main(_hartid: usize) -> ! {
}
}
-#[naked]
-#[link_section = ".text.init"]
-#[export_name = "_start"]
-unsafe extern "C" fn _start() -> ! {
- // At boot, the hart is in privilege mode M, mstatus fields MIE
- // and MPRV are 0, the pc is set to a reset vector, the mcause
- // register specifies why the reset occurred.
- // c.f.: [^super::rism2] § 3.4 (Reset)
- asm!(
- ".option push",
- ".option norelax",
- "la gp, __global_pointer$",
- ".option pop",
-
- "csrr a0, mhartid",
- "la sp, _stack_top",
-
- "tail main",
- options(noreturn)
- )
-}
-
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
if let Some(loc) = info.location() {