Problem getting eth_client.rs to work

Hey,

after some successful first steps in rust and getting to blink something and reading some I²C device on my STM32H730 custom board, for days now I'm trying to get the eth_client.rs running.

In line 22 I had to change RNG to HASH_RNG as I learned here, and of course adjust some pin numbers to my board.

I put a

  • info!("Hello World!"); right behind async fn main(spawner: Spawner) -> ! { (line 33) and a
  • info!("I'm here!"); right behind line 68.

It compiles without warnings or errors, but no output is generated, not even the first, "Hello World!".

Then I tried to cook it down, and commented out everything inside loop { } and piecewise parts from before, more and more upwards. It compiles without errors (some warnings of unused stuff, of course). I get my expected output as soon as I commented out this part of the code (and everything behind):

    let device = Ethernet::new(
        PACKETS.init(PacketQueue::<16, 16>::new()),
        p.ETH,
        Irqs,
        p.PA1,
        p.PA2,
        p.PC1,
        p.PA7,
        p.PC4,
        p.PC5,
        p.PB12,
        p.PB13,
        p.PB11,
        GenericSMI::new(0),
        mac_addr,
    );

Strangely: Even the "Hello World!" from before these lines doesn't appear in the output, if these line are uncommented.

For a test I inserted

    let mut a=PACKETS.init(PacketQueue::<16, 16>::new());
    let mut b=GenericSMI::new(0);

instead the let device statement - output is there. So, these two initializations are not the problem.

Question is, how can I track this down any further? What I don't understand the most: Why is even the output of "Hello World!" from before disappearing?

I totally lack of foundations in rust, that's why I'm so stuck. I just don't really know to the fullest, what I'm doing there, so sorry for the noob question. I appreciate any hints where to look at.

Correction:

This line kills all output from before, but the output after this is seen. In contrary to the let device = Ethernet::new instantiation, which kills all output - before and after that.

So, minimal example:

#![no_std]
#![no_main]

use defmt::*;
use embassy_executor::Spawner;
// use embassy_stm32::eth::PacketQueue;
// use embassy_net::{Stack, StackResources};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(spawner: Spawner) -> ! {
    info!("Hello World!");
    // static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
    info!("I'm here1!");
    // let a=PACKETS.init(PacketQueue::<16, 16>::new());
    info!("I'm here2!");

    loop {
    }
}

Output:

0.000000 INFO  Hello World!
└─ womolin_power::____embassy_main_task::{async_fn#0} @ src/main.rs:38  
0.000000 INFO  I'm here1!
└─ womolin_power::____embassy_main_task::{async_fn#0} @ src/main.rs:90  
0.000000 INFO  I'm here2!
└─ womolin_power::____embassy_main_task::{async_fn#0} @ src/main.rs:92  

Not working:

#![no_std]
#![no_main]

use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::eth::PacketQueue;
use embassy_net::{Stack, StackResources};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(spawner: Spawner) -> ! {
    info!("Hello World!");
    static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
    info!("I'm here1!");
    let a=PACKETS.init(PacketQueue::<16, 16>::new());
    info!("I'm here2!");

    loop {
    }
}

Output:

0.000000 INFO  I'm here2!
└─ womolin_power::____embassy_main_task::{async_fn#0} @ src/main.rs:92  

You're probably running out of RAM. The numbers in PacketQueue<16, 16> are the queue size for RX and TX. (16+16)*1514 = 48kb which is quite a lot.

Reduce it to something like 2 or 4 and it should work.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.