Hey Chris, (and RTEMS users)

Thanks for the response and suggested alternative method of setting the MAC address. After changing to your method, I found I still had the same issues with networking. However, I did discover and fix my issue and it doesn't have anything to do with RTEMS. Sorry!

After doing some more research I found that I was setting the first octet of the MAC address to 0x0f, which because the lowest bit is a 1, is a Multicast MAC address and not a Unicast address. It was therefore not being passed up to the network stack.

Lesson: Don't just randomly select an odd number for the first octet of your MAC address for testing.

Have a great day!

Thanks again,

-Rick

On 11/8/20 6:17 PM, Chris Johns wrote:
On 6/11/20 2:19 am, rvanderwal wrote:
Good Morning,

I seem to be having an issue with RTEMS 5.1 Release Libbsd networking when I
include my own 'rtems_bsd_get_mac_address' function as described in
rtemsbsd/include/rtems/bsd/bsd.h. I'm running on a Xilinx Microzed using
xilinx_zynq_zedboard BSP and have a minimal RTEMS console application (source
code included below). The rc.conf file configures the cgem0 interface and starts
FTP and telnet daemons.

If I include the 'rtems_bsd_get_mac_address' function, the mac address is set
but RTEMS doesn't respond to any pings and doesn't allow any connections.
However, a ping to an external device from RTEMS is successful. I have run
tcpdump filtering on ICMP messages and RTEMS sees them.

If I comment out the 'rtems_bsd_get_mac_address' function, it has the default
mac address and everything works as expected.

All guidance and help are greatly appreciated.
I have commented in the code fragments below.

Thanks,
Rick


//
// RTEMS_Main.c
//
#include <bsp.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <rtems/ramdisk.h>
#include <rtems/printer.h>
#include <rtems/stackchk.h>
#include <rtems/bsd/bsd.h>
#include <rtems/media.h>
#include <machine/rtems-bsd-rc-conf.h>
#include <rtems/ftpd.h>

#include <rtems/console.h>
#include <rtems/shell.h>

#include <stdint.h>

void rtems_bsd_get_mac_address(const char* name, int unit, uint8_t mac_addr[6])
{
     mac_addr[0] = 0x0f;
     mac_addr[1] = 0xc0;
     mac_addr[2] = 0xcb;
     mac_addr[3] = 0x6f;
     mac_addr[4] = 0xcb;
     mac_addr[5] = 0x22;
}
Interesting, I did not know this existed. I prefer following the same process
FreeBSD provides and uses. See below.

static void start_console(void)
{
     rtems_status_code sc = rtems_shell_init(
         "SHLL",
         32 * 1024,
         1,
         CONSOLE_DEVICE_NAME,
         true,
         true,
         NULL
     );
     assert(sc == RTEMS_SUCCESSFUL);
}

static void network_init(void)
{
     printf("BSD\n");
     rtems_status_code sc = rtems_bsd_initialize();
     assert(sc == RTEMS_SUCCESSFUL);

     sc = rtems_task_wake_after( 1000 );
     assert(sc == RTEMS_SUCCESSFUL);
    printf("Config\n");
     // configure bsd networking by specifying configuration file, wait forever,
verbose = true
     rtems_bsd_run_rc_conf("/media/mmcsd-0-0/rc.conf", 0, true);
I suggest specifying the MAC address for the interface in rc.conf. For a Zync I
have something like:

ifconfig_cgem0="DHCP rxcsum txcsum"
ifconfig_cgem0_alias0="ether 0f:c0:cb:6f:cb:22"

I generate the rc.conf file writing it to /etc/rc.conf. This lets me read a MAC
address from what ever piece of hardware has been placed on the board.

Chris

}

void *main_thread(void *arg)
{
   printf("Media Server\n");
   rtems_media_server_initialize(
         25,
         32 * 1024,
         RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | 
RTEMS_INTERRUPT_LEVEL(0),
         RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL );
  rtems_status_code sc = rtems_task_wake_after( 1000 );
   assert(sc == RTEMS_SUCCESSFUL);

   network_init();
  sc = rtems_task_wake_after( 1000 );
   assert(sc == RTEMS_SUCCESSFUL);
  start_console();

   assert(0);
}

/*
  * Configure LibBSD.
  */
#define RTEMS_BSD_CONFIG_NET_PF_UNIX
#define RTEMS_BSD_CONFIG_NET_IF_BRIDGE
#define RTEMS_BSD_CONFIG_NET_IF_LAGG
#define RTEMS_BSD_CONFIG_NET_IF_VLAN
#define LIBBSP_ARM_XILINX_ZYNQ_BSP_H
#define RTEMS_BSD_CONFIG_BSP_CONFIG
#define RTEMS_BSD_CONFIG_SERVICE_TELNETD
#define RTEMS_BSD_CONFIG_SERVICE_FTPD
#define RTEMS_BSD_CONFIG_INIT

#include <machine/rtems-bsd-config.h>

/*
  * Configure Shell
  */
#define CONFIGURE_SHELL_COMMANDS_INIT

#include <bsp/irq-info.h>

#include <rtems/netcmds-config.h>

#ifdef RTEMS_BSD_MODULE_USER_SPACE_WLANSTATS
   #define SHELL_WLANSTATS_COMMAND &rtems_shell_WLANSTATS_Command,
#else
   #define SHELL_WLANSTATS_COMMAND
#endif

#ifdef RTEMS_BSD_MODULE_USR_SBIN_WPA_SUPPLICANT
   #define SHELL_WPA_SUPPLICANT_COMMAND &rtems_shell_WPA_SUPPLICANT_Command,
#else
   #define SHELL_WPA_SUPPLICANT_COMMAND
#endif

#define CONFIGURE_SHELL_USER_COMMANDS \
   SHELL_WLANSTATS_COMMAND \
   SHELL_WPA_SUPPLICANT_COMMAND \
   &bsp_interrupt_shell_command, \
   &rtems_shell_ARP_Command, \
   &rtems_shell_HOSTNAME_Command, \
   &rtems_shell_PING_Command, \
   &rtems_shell_ROUTE_Command, \
   &rtems_shell_NETSTAT_Command, \
   &rtems_shell_IFCONFIG_Command, \
   &rtems_shell_TCPDUMP_Command, \
   &rtems_shell_SYSCTL_Command, \
   &rtems_shell_VMSTAT_Command

#define CONFIGURE_SHELL_COMMANDS_ALL

#include <rtems/shellconfig.h>

/*
  * Configure RTEMS.
  */
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER

#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK

#define CONFIGURE_FILESYSTEM_DEVFS
#define CONFIGURE_FILESYSTEM_DOSFS
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32

#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1

#define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32
#define CONFIGURE_UNLIMITED_OBJECTS
#define CONFIGURE_UNIFIED_WORK_AREAS

#define CONFIGURE_STACK_CHECKER_ENABLED

#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024)
#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4
#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024)

#define CONFIGURE_MAXIMUM_POSIX_THREADS 20
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT main_thread

#define CONFIGURE_MAXIMUM_PROCESSORS 2
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_TICKS_PER_TIMESLICE 50

#define CONFIGURE_SCHEDULER_PRIORITY_SMP

#define CONFIGURE_INIT

#include <rtems/confdefs.h>



_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Reply via email to