initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
[unstable]
weak-dep-features = true
[target.thumbv7em-none-eabihf]
# uncomment this to make `cargo run` execute programs on QEMU
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
# runner = "probe-run --chip AMA3B1KK-KBR"
runner = "../../tools/objcopy-bootload-svl.sh"
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
rustflags = [
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
"-C", "link-arg=--nmagic",
# LLD (shipped with the Rust toolchain) is used as the default linker
"-C", "link-arg=-Tlink.x",
# if you run into problems with LLD switch to the GNU linker by commenting out
# this line
# "-C", "linker=arm-none-eabi-ld",
# if you need to link to pre-compiled C libraries provided by a C toolchain
# use GCC as the linker by commenting out both lines above and then
# uncommenting the three lines below
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tmemory.x",
# "-C", "link-arg=-nostartfiles",
]
[build]
# Pick ONE of these compilation targets
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
#target = "thumbv7m-none-eabi" # Cortex-M3
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
# target = "thumbv8m.base-none-eabi" # Cortex-M23
# target = "thumbv8m.main-none-eabi" # Cortex-M33 (no FPU)
# target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU)
+20
View File
@@ -0,0 +1,20 @@
[package]
name = "flashdev"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
panic-halt = "0.2.0"
cortex-m-rt = { version = "0.7.0"}
cortex-m = "0.7.3"
cty = "0.2.2"
[dependencies.ambiq-hal]
path = "../../ambiq-hal"
features = [ "ambiq-sdk", "sparkfun-redboard-nano", "rt"]
[dev-dependencies]
rtt-target = { version = "*", features = [ "cortex-m" ] }
ufmt = "*"
+31
View File
@@ -0,0 +1,31 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
}
+120
View File
@@ -0,0 +1,120 @@
ENTRY(Reset_Handler)
MEMORY
{
/* FLASH (rx) : ORIGIN = 0x0000C000, LENGTH = (960K - (0xc000)) */
/* RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 384K */
FLASH (rx) : ORIGIN = 0x00010000, LENGTH = (960K - (0x10000))
RAM_NVIC (rwx) : ORIGIN = 0x10000000, LENGTH = 0x100
RAM (rwx) : ORIGIN = (0x10000000 + 0x100), LENGTH = (384K - 0x100)
}
/* SECTIONS */
/* { */
/* .text : */
/* { */
/* . = ALIGN(4); */
/* _stext = .; */
/* KEEP(*(.vector_table.interrupts)) */
/* *(.text) */
/* *(.text*) */
/* } */
/* SECTIONS */
/* { */
/* .text : */
/* { */
/* . = ALIGN(4); */
/* _stext = .; */
/* KEEP(*(.isr_vector)) */
/* KEEP(*(.ble_patch)) */
/* *(.text) */
/* *(.text*) */
/* KEEP(*(.init)) */
/* KEEP(*(.fini)) */
/* *crtbegin.o(.ctors) */
/* *crtbegin?.o(.ctors) */
/* *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) */
/* *(SORT(.ctors.*)) */
/* *(.ctors) */
/* *crtbegin.o(.dtors) */
/* *crtbegin?.o(.dtors) */
/* *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) */
/* *(SORT(.dtors.*)) */
/* *(.dtors) */
/* . = ALIGN(4); */
/* *(.rodata) */
/* *(.rodata*) */
/* KEEP(*(.eh_frame*)) */
/* . = ALIGN(4); */
/* } > FLASH */
/* .ARM.extab : */
/* { */
/* *(.ARM.extab* .gnu.linkonce.armextab.*) */
/* } > FLASH */
/* __exidx_start = .; */
/* .ARM.exidx : */
/* { */
/* *(.ARM.exidx* .gnu.linkonce.armexidx.*) */
/* } > FLASH */
/* __exidx_end = .; */
/* __etext = ALIGN(8); */
/* .data : AT (__etext) */
/* { */
/* __data_start__ = .; */
/* *(.data*) */
/* . = ALIGN(8); */
/* PROVIDE_HIDDEN (__preinit_array_start = .); */
/* KEEP(*(.preinit_array)) */
/* PROVIDE_HIDDEN (__preinit_array_end = .); */
/* . = ALIGN(8); */
/* PROVIDE_HIDDEN (__init_array_start = .); */
/* KEEP(*(SORT(.init_array.*))) */
/* KEEP(*(.init_array)) */
/* PROVIDE_HIDDEN (__init_array_end = .); */
/* . = ALIGN(8); */
/* PROVIDE_HIDDEN (__fini_array_start = .); */
/* KEEP(*(SORT(.fini_array.*))) */
/* KEEP(*(.fini_array)) */
/* PROVIDE_HIDDEN (__fini_array_end = .); */
/* KEEP(*(.jcr*)) */
/* . = ALIGN(8); */
/* __data_end__ = .; */
/* } > RAM */
/* .uninitialized (NOLOAD): */
/* { */
/* . = ALIGN(32); */
/* __uninitialized_start = .; */
/* *(.uninitialized) */
/* KEEP(*(.keep.uninitialized)) */
/* . = ALIGN(32); */
/* __uninitialized_end = .; */
/* } > RAM */
/* .bss : */
/* { */
/* . = ALIGN(8); */
/* _sbss = .; */
/* __bss_start__ = .; */
/* *(.bss) */
/* *(.bss*) */
/* *(COMMON) */
/* . = ALIGN(8); */
/* _ebss = .; */
/* __bss_end__ = .; */
/* } > RAM */
/* .heap (NOLOAD): */
/* { */
/* . = ALIGN(4); */
/* __end__ = .; */
/* PROVIDE( end = . ); */
/* _sheap = .; */
/* . = ORIGIN(RAM) + LENGTH(RAM) - 0x400 -8; */
/* __HeapLimit = .; */
/* } >RAM */
/* .stack_dummy (NOLOAD): */
/* { */
/* . = ALIGN(8); */
/* *(.stack*) */
/* } > RAM */
/* __StackTop = ORIGIN(RAM) + LENGTH(RAM)-8; */
/* __StackLimit = __StackTop - 0x400; */
/* PROVIDE(__stack = __StackTop); */
/* PROVIDE(_sstack = __StackTop); */
/* } */
+29
View File
@@ -0,0 +1,29 @@
use cty::*;
#[repr(C)]
struct SECTOR_INFO {
SectorSize: u32, // Sector Size in bytes
SectorStartAddr: u32, // Start address of the sector area (relative to the "BaseAddr" of the flash)
}
#[repr(C)]
pub struct FlashDevice {
AlgoVer: u16, // Algo version number
Name: [u8; 128], // Flash device name. NEVER change the size of this array!
Type: u16, // Flash device type
BaseAddr: u32, // Flash base address
TotalSize: u32, // Total flash device size in Bytes (256 KB)
PageSize: u32, // Page Size (number of bytes that will be passed to ProgramPage(). MinAlig is 8 byte
Reserved: u32, // Reserved, should be 0
ErasedVal: u8, // Flash erased value
TimeoutProg: u32, // Program page timeout in ms
TimeoutErase: u32, // Erase sector timeout in ms
SectorInfo: [SECTOR_INFO; 4], // Flash sector layout definition. May be adapted up to 512 entries
}
static FlashDevice: FlashDevice = FlashDevice {
AlgoVer: 0,
Name:
};
+20
View File
@@ -0,0 +1,20 @@
#![no_std]
#![no_main]
#![allow(non_snake_case)]
use panic_halt as _;
pub mod flashdev;
use ambiq_hal as hal;
use cortex_m_rt::entry;
use cortex_m;
#[entry]
fn main() -> ! {
// println!("Hello, world!");
loop {
cortex_m::asm::nop();
}
}