issue in lib_ethernet: crash on ethernet link up

Technical questions regarding the XTC tools and programming with XMOS.
fabra
Active Member
Posts: 35
Joined: Sat May 09, 2020 4:20 pm

issue in lib_ethernet: crash on ethernet link up

Post by fabra »

I am using AN00202_gige_avb_i2s_demo and I reduced the main function to the following in order to isolate the issue:

Code: Select all

int main(void)
{
  // Ethernet interfaces and channels
  ethernet_cfg_if i_eth_cfg[NUM_ETH_CFG_CLIENTS];
  ethernet_rx_if i_eth_rx_lp[NUM_ETH_RX_LP_CLIENTS];
  ethernet_tx_if i_eth_tx_lp[NUM_ETH_TX_LP_CLIENTS];
  streaming chan c_eth_rx_hp;
  streaming chan c_eth_tx_hp;
  smi_if i_smi;
  streaming chan c_rgmii_cfg;

  // PTP channels
  chan c_ptp[NUM_PTP_CHANS];

  // AVB unit control
  chan c_talker_ctl[AVB_NUM_TALKER_UNITS];
  chan c_listener_ctl[AVB_NUM_LISTENER_UNITS];
  chan c_buf_ctl[AVB_NUM_LISTENER_UNITS];

  // Media control
  chan c_media_ctl[AVB_NUM_MEDIA_UNITS];
  interface media_clock_if i_media_clock_ctl;

  // Core AVB interface and callbacks
  interface avb_interface i_avb[NUM_AVB_MANAGER_CHANS];
  interface avb_1722_1_control_callbacks i_1722_1_entity;

  // I2C and GPIO interfaces
  i2c_master_if i_i2c[NUM_I2C_IFS];
  interface output_gpio_if i_gpio[4];

  // I2S and audio buffering interfaces
  i2s_callback_if i_i2s;
  streaming chan c_audio;
  interface push_if i_audio_in_push;
  interface pull_if i_audio_in_pull;
  interface push_if i_audio_out_push;
  interface pull_if i_audio_out_pull;
  streaming chan c_sound_activity;

  par
  {
    on tile[1]: rgmii_ethernet_mac(i_eth_rx_lp, NUM_ETH_RX_LP_CLIENTS,
                                   i_eth_tx_lp, NUM_ETH_TX_LP_CLIENTS,
                                   c_eth_rx_hp, c_eth_tx_hp,
                                   c_rgmii_cfg,
                                   rgmii_ports,
                                   ETHERNET_DISABLE_SHAPER);

    on tile[1].core[0]: rgmii_ethernet_mac_config(i_eth_cfg, NUM_ETH_CFG_CLIENTS, c_rgmii_cfg);
    on tile[1].core[0]: ar8035_phy_driver(i_smi, i_eth_cfg[MAC_CFG_TO_PHY_DRIVER], c_sound_activity);

    on tile[1]: [[distribute]] smi(i_smi, p_smi_mdio, p_smi_mdc);
#if 0
...
#endif
  }

  return 0;
}
 
in ar8035_phy_driver() I added:

Code: Select all

      if (new_state != link_state) {
        link_state = new_state;
        eth.set_link_state(0, new_state, link_speed);
        debug_printf("new link state\n");
      }
unplugging and reconnecting the ethernet cable leads to the following crash (repeating that sequence multiple times - leads to crash in aprox 1 out of 10 repititions):

Code: Select all

new link state
new link state
new link state
new link state
new link state
new link state
xrun: Program received signal ET_LOAD_STORE, Memory access exception.
      mii_init_lock () at /home/fabra/projects/XMOS_orig/lib_ethernet/src/mii_buffering.c:90
      90	    if (ethernet_memory_lock == 0) {
      Current language:  auto; currently minimal
has anyone seen and solved this issue before?
Last edited by fabra on Thu Sep 21, 2023 6:20 am, edited 1 time in total.


User avatar
CousinItt
Respected Member
Posts: 365
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Often the ET_LOAD_STORE exception is caused by dual-issue code accessing data that isn't aligned to a 64-bit boundary. As far as I know there isn't a pragma to force this to happen, but it can be worked around by putting data in global space or defining buffers of 32-bit ints as arrays of 64-bit ints and then casting.

If you make a google search for
"ET_LOAD_STORE" site:xcore.com
there are various suggestions that will help.