Skip to content

Commit

Permalink
Fixed: panic at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinevg committed Jul 15, 2022
1 parent 62cfa8d commit 11142b2
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->

## [0.2.0] - 2022-07-02
### Fixed
- Panic at start due to `cortex-m-rt = 0.7.x` memory layout changes. (Ref: [rust-embedded/cortex-m #426](https://github.com/rust-embedded/cortex-m/issues/426#issuecomment-1092384050)]
### Changed
- Update `cortex-m` to `0.7.5`
- Update `cortex-m-rt` to `0.7.1`
Expand Down
63 changes: 32 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nucleo-h7xx"
version = "0.2.0"
authors = ["Antoine van Gelder <antoine@flowdsp.io>"]
authors = [ "Antoine van Gelder <antoine@flowdsp.io>" ]
edition = "2018"
license = "MIT"
description = "Board support crate for the STMicroelectronics STM32H7 Nucleo-144 boards."
Expand All @@ -27,8 +27,8 @@ exclude = [
]

[package.metadata.docs.rs]
features = [ ]
targets = ["thumbv7em-none-eabihf"]
features = []
targets = [ "thumbv7em-none-eabihf" ]


# - workspace -----------------------------------------------------------------
Expand All @@ -40,51 +40,52 @@ targets = ["thumbv7em-none-eabihf"]
#]


# - features ------------------------------------------------------------------

[features]
default = []
ethernet = [ "stm32h7xx-hal/ethernet", "smoltcp" ]
button-1-pa0 = [] # SB81=on, SB82=off
led-1-pa5 = [] # SB65=on, SB54=off
log-semihosting = [ "cortex-m-semihosting" ]
log-itm = []
log-rtt = []


# - dependencies --------------------------------------------------------------

[dependencies]
cortex-m = "0.7.5"
cortex-m-rt = { version = "0.7.1" }
cortex-m-semihosting = { version = "0.5.0" }
embedded-timeout-macros = { version = "0.3.0" }
heapless = { version = "0.6.0", default_features = true }
stm32h7xx-hal = { version = "0.12.2", features = [ "stm32h747cm7" ] }

embedded-timeout-macros = "0.3.0"
heapless = "0.6.0"
nb = "1.0.0"
void = { version = "1.0.2", default-features = false }

[dependencies.stm32h7xx-hal]
version = "0.12.2"
features = [ "stm32h747cm7", "rt" ]

[dependencies.smoltcp]
version = "0.8.1"
default-features = false
features = ["medium-ethernet", "proto-ipv4", "proto-ipv6", "socket-raw", "socket-udp"]
optional = true
cortex-m-semihosting = { version = "0.5.0", optional = true } #, features = [ "jlink-quirks" ] }
smoltcp = { version = "0.8.1", optional = true, default-features = false, features = [
"medium-ethernet",
"proto-ipv4",
"proto-ipv6",
"socket-raw",
"socket-udp"
] }


# - dev dependencies ----------------------------------------------------------

[dev-dependencies]
cfg-if = "1.0.0"
cortex-m-log = { version = "~0.7.0", features = ["itm", "semihosting", "log-integration"] }
lazy_static = { version = "~1.4.0", features = ["spin_no_std"] }
cortex-m-log = { version = "~0.7.0", features = [ "itm", "semihosting", "log-integration" ] }
lazy_static = { version = "~1.4.0", features = [ "spin_no_std" ] }
log = "0.4.14"
panic-halt = "0.2.0"
panic-itm = { version = "~0.4.2" }
panic-rtt-target = { version = "~0.1.1", features = ["cortex-m"] }
panic-rtt-target = { version = "~0.1.1", features = [ "cortex-m" ] }
panic-semihosting = { version = "~0.5.3" }
rtt-target = { version = "~0.3.1", features = ["cortex-m"] }

# - features ------------------------------------------------------------------

[features]
default = [ "ethernet" ]
ethernet = [ "stm32h7xx-hal/ethernet", "smoltcp" ]
button-1-pa0 = [] # SB81=on, SB82=off
led-1-pa5 = [] # SB65=on, SB54=off
log-semihosting = []
log-itm = []
log-rtt = []
rtt-target = { version = "~0.3.1", features = [ "cortex-m" ] }


# - profiles ------------------------------------------------------------------
Expand Down Expand Up @@ -115,7 +116,7 @@ required-features = [ "ethernet" ]

[[example]]
name = "ethernet_hal"
required-features = [ "ethernet" ]
required-features = [ "ethernet", "log-semihosting" ]

[[example]]
name = "itm"
Expand Down
2 changes: 1 addition & 1 deletion examples/ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use log::{debug, error, info};
const MAC_LOCAL: [u8; 6] = [0x02, 0x00, 0x11, 0x22, 0x33, 0x44];
const IP_LOCAL: [u8; 4] = [192, 168, 20, 99];
const IP_REMOTE: [u8; 4] = [192, 168, 20, 114];
const IP_REMOTE: [u8; 4] = [192, 168, 20, 207];
const IP_REMOTE_PORT: u16 = 34254;

mod utilities;
Expand Down
2 changes: 1 addition & 1 deletion examples/ethernet_hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, IpEndpoint, Ipv4Address,

const MAC_LOCAL: [u8; 6] = [0x02, 0x00, 0x11, 0x22, 0x33, 0x44];
const IP_LOCAL: [u8; 4] = [192, 168, 20, 99];
const IP_REMOTE: [u8; 4] = [192, 168, 20, 114];
const IP_REMOTE: [u8; 4] = [192, 168, 20, 207];
const IP_REMOTE_PORT: u16 = 34254;

const MAX_UDP_PACKET_SIZE: usize = 576;
Expand Down
7 changes: 5 additions & 2 deletions memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ MEMORY
REGION_ALIAS(RAM, DTCMRAM);
REGION_ALIAS(FLASH, FLASH1);

/* The location of the stack can be overridden using the
`_stack_start` symbol. Place the stack at the end of RAM */
_stack_start = ORIGIN(RAM) + LENGTH(RAM);

SECTIONS
{
.itcmram : ALIGN(4) {
Expand Down Expand Up @@ -51,5 +55,4 @@ SECTIONS
*(.sram4 .sram4.*);
. = ALIGN(4);
} > SRAM4

} INSERT AFTER .bss;
};
5 changes: 4 additions & 1 deletion openocd.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
source [find board/st_nucleo_h745zi.cfg]
# semi-hosting support doesn't work
#source [find board/st_nucleo_h745zi.cfg]
source [find interface/stlink.cfg]
source [find target/stm32h7x.cfg]
1 change: 1 addition & 0 deletions src/clocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub fn configure_with(
ccdr
}

#[cfg(any(feature = "log-itm", feature = "log-semihosting"))]
pub fn log_clocks(clocks: &hal::rcc::CoreClocks) {
use crate::loggit;

Expand Down
16 changes: 6 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ pub mod itm;

// - log macros ---------------------------------------------------------------

#[cfg(any(feature = "log-itm"))]
#[macro_export]
macro_rules! loggit {
($($arg:tt)*) => (
let itm = unsafe { &mut *cortex_m::peripheral::ITM::PTR };
cortex_m::iprintln!(&mut itm.stim[0], $($arg)*);
)
}

#[cfg(not(feature = "log-itm"))]
#[macro_export]
macro_rules! loggit {
($($arg:tt)*) => (
#[cfg(feature = "log-itm")]
{
let itm = unsafe { &mut *cortex_m::peripheral::ITM::PTR };
cortex_m::iprintln!(&mut itm.stim[0], $($arg)*);
}
#[cfg(feature = "log-semihosting")]
cortex_m_semihosting::hprintln!($($arg)*);
)
}
Expand Down

0 comments on commit 11142b2

Please sign in to comment.