boards: Added board nucleo_u545re_q#4803
Conversation
bradjc
left a comment
There was a problem hiding this comment.
Looks pretty good, just a couple notes about unsafe.
I'm not sure if it is now, but we really should start using tockloader local-board (if necessary) rather than make/objcopy manual fix ups. Using objcopy makes it nearly impossible to run more than one app. Ideally tockloader just works, but the local-board mechanism is basically just as seemless if there isn't a good way to do partial writes to a chip.
| ## Flashing Notes | ||
|
|
||
| This board is flashed using **`probe-rs`** or **`openocd`**. Due to the specific | ||
| memory layout and metadata sections of the STM32U5, the Makefile surgically | ||
| extracts executable sections (stripping metadata like `.ARM.attributes`) before | ||
| flashing to prevent errors when writing to protected system memory addresses. |
There was a problem hiding this comment.
Is the binary file the make system builds not suitable? I would prefer to avoid have custom elf/obcopy logic per-board if we can avoid it. That would seem to suggest the linker script is wrong for this board if it is required, and perhaps we should fix the issue with the linker script so we can document exactly what the requirements are.
There was a problem hiding this comment.
@FarhadGUL06 do we have this problem on other boards? Those sections should not be loaded to the board, but I agree with @bradjc that we should rely on the ELF file and not do objcopy.
There was a problem hiding this comment.
I have made some changes to tockloader and modified the current Makefile to be similar to the one for the nucleo_f429zi. I also tested installing two apps: a modified version of blink (which blinks the LED every 2 seconds but also toggles the LED when the user button is pressed) and c_hello.
Running "make flash" flashes only the kernel, and "tockloader install --openocd --board nucleo_u545re_q" loads the application from the current folder to the board. An application can also be loaded using "make program" (as explained in the README). Both applications work and can be seen as loaded by using "tockloader list --openocd --board nucleo_u545re_q".
I think the flash layout should allow us to use tockloader, meaning it is split in pages of the same size. The manual's section 7.3.1 at page 292 says the flash is spilt up in two banks and has pages of 8KB and that the flash supports
if |
34b8590 to
07eb27c
Compare
| } | ||
| } | ||
|
|
||
| pub fn match_channel(&self, channel: ChannelId) -> Option<usize> { |
There was a problem hiding this comment.
I suggest implementing From<DmaChannel> for usize and that will allow the use of dam_channel.into().
There was a problem hiding this comment.
We can delete this function and just use into.
alexandruradovici
left a comment
There was a problem hiding this comment.
Please use the tock-registers register fields for all the peripherals.
alexandruradovici
left a comment
There was a problem hiding this comment.
Please use the tock-registers register fields for all the peripherals.
|
Hi, @bradjc ! Could you please take a look at my latest commits when you have a moment? Thanks! |
| if let (Some(tx), Some(rx)) = (usart1_channel_tx, usart1_channel_rx) { | ||
| stm32u545::usart::Usart::set_dma(usart1, dma1, tx, rx); | ||
| } | ||
|
|
There was a problem hiding this comment.
Can this be moved to Stm32u5xxPeripherals::configure() (or some suitable name)?
There was a problem hiding this comment.
Moved all chip wiring to init function from Stm32u5xxDefaultPeripherals
| pub struct Stm32u5xxPeripherals<'a> { | ||
| pub rcc: rcc::Rcc, | ||
| pub exti: &'a exti::Exti<'a>, | ||
| pub dma1: &'a dma::Dma, | ||
| pub gpio_a: gpio::Port<'a>, | ||
| pub gpio_c: gpio::Port<'a>, | ||
| pub usart1: &'a usart::Usart<'a>, | ||
| pub tim2: tim::Tim2<'a>, | ||
| } |
There was a problem hiding this comment.
I don't understand why there is this peripherals and the default peripherals.
There was a problem hiding this comment.
Stm32u5xxDefaultPeripherals was indeed created to implement InterruptService and Stm32u5xxPeripherals for the board but i see the point and i will combine those.
|
I really thought I commented this already, but I think we need to include DmaSlice (https://github.com/tock/tock/blob/master/chips/nrf52/src/uart.rs#L166) and PanicWriter (https://github.com/tock/tock/blob/master/chips/nrf52/src/uart.rs#L802) in this PR. It is a bit of bad timing, but otherwise we keep making it more difficult to get to correct/sound chips. |
3042c2c to
f64e7b7
Compare
|
Hi @bradjc ! |
| let _ = periphs.usart1.configure(kernel::hil::uart::Parameters { | ||
| baud_rate: 115200, | ||
| stop_bits: kernel::hil::uart::StopBits::One, | ||
| parity: kernel::hil::uart::Parity::None, | ||
| hw_flow_control: false, | ||
| width: kernel::hil::uart::Width::Eight, | ||
| }); |
There was a problem hiding this comment.
I believe this is handled here: https://github.com/tock/tock/blob/master/boards/components/src/console.rs#L97
| /// Writer is used by kernel::debug to print messages to the serial port. | ||
| pub struct Writer {} | ||
|
|
||
| /// Global static for debug writer | ||
| #[no_mangle] | ||
| pub static mut WRITER: Writer = Writer {}; | ||
|
|
||
| impl Write for Writer { | ||
| fn write_str(&mut self, s: &str) -> core::fmt::Result { | ||
| self.write(s.as_bytes()); | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl IoWrite for Writer { | ||
| fn write(&mut self, buf: &[u8]) -> usize { | ||
| let uart = stm32u545::usart::Usart::new(stm32u545::usart::USART1_BASE); | ||
|
|
||
| for &c in buf { | ||
| uart.transmit_byte(c); | ||
| } | ||
| buf.len() | ||
| } | ||
| } |
There was a problem hiding this comment.
| /// Writer is used by kernel::debug to print messages to the serial port. | |
| pub struct Writer {} | |
| /// Global static for debug writer | |
| #[no_mangle] | |
| pub static mut WRITER: Writer = Writer {}; | |
| impl Write for Writer { | |
| fn write_str(&mut self, s: &str) -> core::fmt::Result { | |
| self.write(s.as_bytes()); | |
| Ok(()) | |
| } | |
| } | |
| impl IoWrite for Writer { | |
| fn write(&mut self, buf: &[u8]) -> usize { | |
| let uart = stm32u545::usart::Usart::new(stm32u545::usart::USART1_BASE); | |
| for &c in buf { | |
| uart.transmit_byte(c); | |
| } | |
| buf.len() | |
| } | |
| } |
|
Hi @bradjc ! I've made the final changes you requested. Is there anything else that needs to be changed? If there are any more changes to be made, could you let me know all of them for the current version? I'd like us to get this up and running as soon as possible. Thanks! |
Pull Request Overview
This pull request adds support for the Nucleo-U545RE-Q board (STM32U545) to Tock OS. It introduces a new stm32u5xx chip crate designed for the ultra-low-power STM32U5 series, with a specific focus on Secure Mode operation and TrustZone compatibility.
Features implemented:
Testing Strategy
This pull request was tested on a physical Nucleo-U545RE-Q hardware target.
-- Verified kernel boot and console output at 115200 baud via USART1.
-- Verified that the User Button (PC13) triggers asynchronous interrupts to toggle the User LED (PA5).
-- Verified userspace delay_ms functionality using the TIM2-backed Alarm HIL.
-- Validated the GPDMA1 configuration (Request ID 25) for stable background printing.
TODO or Help Wanted
This pull request still needs:
Documentation Updated
Formatting
make prepush.cargo fmt.AI Use