diff --git a/firmware/build.rs b/firmware/build.rs index 8709ff2..143e014 100644 --- a/firmware/build.rs +++ b/firmware/build.rs @@ -11,4 +11,4 @@ fn main() { println!("cargo:rerun-if-changed=memory.x"); println!("cargo:rerun-if-changed=build.rs"); -} \ No newline at end of file +} diff --git a/firmware/build_and_strip.sh b/firmware/build_and_strip.sh new file mode 100755 index 0000000..4e17ac0 --- /dev/null +++ b/firmware/build_and_strip.sh @@ -0,0 +1,4 @@ +#!/usr/bin/sh + +cargo build --release +riscv64-unknown-elf-objcopy -S -O binary target/riscv32i-unknown-none-elf/release/fw fw.bin diff --git a/firmware/openocd.cfg b/firmware/openocd.cfg new file mode 100644 index 0000000..3a9aa3a --- /dev/null +++ b/firmware/openocd.cfg @@ -0,0 +1,17 @@ +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x21000000 + +set _TARGETNAME $_CHIPNAME.cpu + +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 + +#flash bank spi0 fespi 0x40000000 0 0 0 $_TARGETNAME.0 0x20004000 +init +if {[ info exists pulse_srst]} { + ftdi_set_signal nSRST 0 + ftdi_set_signal nSRST z +} +halt +#flash protect 0 64 last off +echo "Ready for Remote Connections" \ No newline at end of file diff --git a/firmware/src/eth.rs b/firmware/src/eth.rs index 850700c..1aff529 100644 --- a/firmware/src/eth.rs +++ b/firmware/src/eth.rs @@ -1,7 +1,6 @@ //! Quick and hacky ethernet thing to test -const LITEETH_BASE: u32 = 0x0050_0000; - +const LITEETH_BASE: u32 = 0x0200_0000; const ETHMAC_SRAM_WRITER_EV_PENDING: u32 = LITEETH_BASE + 0x810; const ETHMAC_SRAM_WRITER_EV_ENABLE: u32 = LITEETH_BASE + 0x814; @@ -9,12 +8,16 @@ const ETHMAC_SRAM_READER_EV_PENDING: u32 = LITEETH_BASE + 0x830; const ETHMAC_SRAM_READER_EV_ENABLE: u32 = LITEETH_BASE + 0x834; fn write_u32_reg(addr: u32, value: u32) { - unsafe { *(addr as *mut u32) = value; } + use core::ptr::write; + unsafe { + write(addr as *mut u32, value); + } } fn read_u32_reg(addr: u32) -> u32 { + use core::ptr::read; unsafe { - return *(addr as *mut u32); + return read(addr as *mut u32); } } @@ -35,7 +38,4 @@ pub fn init() { write_u32_reg(ETHMAC_SRAM_READER_EV_ENABLE, 0); } -pub fn tranmsit() { - -} - +pub fn tranmsit() {} diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 2e491c0..95ee030 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -21,13 +21,12 @@ fn main() -> ! { 500_000 }; - // do something here loop { unsafe { - write(0x01002000 as *mut u32, 0); + write_led(0); busy_wait(blink_period); - write(0x01002000 as *mut u32, 1); + write_led(1); busy_wait(blink_period); } } @@ -35,10 +34,14 @@ fn main() -> ! { fn busy_wait(num_nops: u32) { for _ in 0..num_nops { - unsafe { asm!("nop"); } + unsafe { + asm!("nop"); + } } } fn write_led(val: u32) { - unsafe { write(0x01002000 as *mut u32, val); } -} \ No newline at end of file + unsafe { + write(0x01002000 as *mut u32, val); + } +}