Skip to content

WiFi optimizations and libbsd to FreeBSD 12 update #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[submodule "rtems"]
path = rtems
url = https://github.com/grisp/rtems
branch = grisp-20171025-patches
url = git://git.rtems.org/rtems.git
branch = master
[submodule "rtems-libbsd"]
path = rtems-libbsd
url = https://github.com/grisp/rtems-libbsd
branch = grisp
url = git://git.rtems.org/rtems-libbsd.git
branch = 5-freebsd-12
[submodule "rtems-source-builder"]
path = rtems-source-builder
url = git://git.rtems.org/rtems-source-builder.git
Expand Down
11 changes: 7 additions & 4 deletions build/build-libbsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ PROJECTDIR="${SCRIPTDIR}/../"
. "${SCRIPTDIR}/configuration.sh"
export PATH="${PREFIX}/bin:${PATH}"

WAF="${PROJECTDIR}/rtems-libbsd/waf"

cd "${LIBBSD_SOURCE_DIR}"

if [ "$BSP_NAME" = "atsamv" ]
Expand Down Expand Up @@ -55,14 +57,15 @@ then
fi
fi

waf configure \
python3 $WAF configure \
--prefix="${PREFIX}" \
--rtems-bsps="${RTEMS_CPU}/${BSP_NAME}"
waf
--rtems-bsps="${RTEMS_CPU}/${BSP_NAME}" \
--buildset="${SCRIPTDIR}/libbsd-buildset.ini"
python3 $WAF

if [ $DO_INSTALL -ne 0 ]
then
waf install
python3 $WAF install
fi

if [ "$BSP_NAME" = "atsamv" ]
Expand Down
11 changes: 11 additions & 0 deletions build/libbsd-buildset.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[general]
name = grisp
extends = default.ini

[modules]
# WiFi
dev_usb_wlan = on
dev_wlan_rtwn = on
net80211 = on
user_space_wlanstats = on
usr_sbin_wpa_supplicant = on
2 changes: 1 addition & 1 deletion grisp-sd-sample/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(BUILDDIR):
mkdir $(BUILDDIR)

$(APP).exe: $(APP_OBJS)
$(CCLINK) $^ -lgrisp -lbsd -lm -o $@
$(CCLINK) $^ -lgrisp -lftpd -lbsd -lm -o $@

$(APP).bin: $(APP).exe
$(OBJCOPY) -O binary $^ $@
Expand Down
7 changes: 4 additions & 3 deletions grisp-sd-sample/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
#include <machine/rtems-bsd-commands.h>

#include <bsp.h>
#include <bsp/stackalloc.h>

#include <grisp/pin-config.h>
#include <grisp/led.h>
#include <grisp/init.h>

#define STACK_SIZE_INIT_TASK (64 * 1024)
#define STACK_SIZE_SHELL (64 * 1024)
#define STACK_SIZE_INIT_TASK (16 * 1024)
#define STACK_SIZE_SHELL (16 * 1024)

#define PRIO_SHELL 150
#define PRIO_LED_TASK (RTEMS_MAXIMUM_PRIORITY - 1)
Expand Down Expand Up @@ -186,9 +187,9 @@ Init(rtems_task_argument arg)
grisp_led_set1(false, false, false);
grisp_led_set2(true, false, false);
puts("\nGRISP RTEMS SD Demo\n");
grisp_init_sd_card();
grisp_init_lower_self_prio();
grisp_init_libbsd();
grisp_init_sd_card();

/* Wait for the SD card */
grisp_led_set2(true, false, true);
Expand Down
108 changes: 40 additions & 68 deletions libgrisp/src/init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 embedded brains GmbH. All rights reserved.
* Copyright (c) 2016, 2018 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
Expand Down Expand Up @@ -37,12 +37,11 @@
#include <unistd.h>
#include <string.h>

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

#include <rtems.h>
#include <rtems/bsd/bsd.h>
#include <rtems/bdbuf.h>
#include <rtems/console.h>
#include <rtems/dhcpcd.h>
#include <rtems/irq.h>
#include <rtems/malloc.h>
#include <rtems/media.h>
Expand Down Expand Up @@ -149,74 +148,29 @@ grisp_init_sd_card(void)
assert(sc == RTEMS_SUCCESSFUL);
}

static void
grisp_init_network_ifconfig_lo0(void)
{
int exit_code;
char *lo0[] = {
"ifconfig",
"lo0",
"inet",
"127.0.0.1",
"netmask",
"255.255.255.0",
NULL
};
char *lo0_inet6[] = {
"ifconfig",
"lo0",
"inet6",
"::1",
"prefixlen",
"128",
"alias",
NULL
};

exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0), lo0);
assert(exit_code == EX_OK);

exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0_inet6), lo0_inet6);
assert(exit_code == EX_OK);
}

static void
network_dhcpcd_task(rtems_task_argument arg)
{
int exit_code;
const char *cconf = (const char*) arg;
char* conf = NULL;
if (cconf && (access(cconf, F_OK | R_OK ) != -1) && (conf = strdup(cconf))) {
char *dhcpcd[] = {"dhcpcd", "-f", conf, NULL};
exit_code = rtems_bsd_command_dhcpcd(RTEMS_BSD_ARGC(dhcpcd), dhcpcd);
free(conf);
} else {
char *dhcpcd[] = {"dhcpcd", NULL};
exit_code = rtems_bsd_command_dhcpcd(RTEMS_BSD_ARGC(dhcpcd), dhcpcd);
}

assert(exit_code == EXIT_SUCCESS);

rtems_task_delete(RTEMS_SELF);
}

void
grisp_init_dhcpcd_with_config(rtems_task_priority prio, const char *conf)
grisp_init_dhcpcd_with_config(rtems_task_priority prio, const char *cfile)
{
rtems_dhcpcd_config config;
rtems_status_code sc;
rtems_id id;

sc = rtems_task_create(
rtems_build_name('D', 'H', 'C', 'P'),
prio,
2 * RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_FLOATING_POINT,
&id
);
assert(sc == RTEMS_SUCCESSFUL);
int argc = 1;
char *argv[] = {"dhcpcd", NULL, NULL, NULL};
char *file = NULL;

if (cfile != NULL && access(cfile, F_OK | R_OK ) == 0 &&
(file = strdup(cfile))) {
argc = 3;
argv[1] = "-f";
argv[2] = file;
}

memset(&config, 0, sizeof(config));
config.priority = prio;
config.argc = argc;
config.argv = argv;

sc = rtems_task_start(id, network_dhcpcd_task, (rtems_task_argument) conf);
sc = rtems_dhcpcd_start(&config);
free(file);
assert(sc == RTEMS_SUCCESSFUL);
}

Expand All @@ -230,13 +184,15 @@ void
grisp_init_libbsd(void)
{
rtems_status_code sc;
int exit_code;

grisp_saf1761_basic_init();

sc = rtems_bsd_initialize();
assert(sc == RTEMS_SUCCESSFUL);

grisp_init_network_ifconfig_lo0();
exit_code = rtems_bsd_ifconfig_lo0();
assert(exit_code == EX_OK);
grisp_wlan_power_up();

/* Let the callout timer allocate its resources */
Expand Down Expand Up @@ -363,3 +319,19 @@ grisp_wlan_power_down(void)
const Pin wlan_en = GRISP_WLAN_EN;
PIO_Set(&wlan_en);
}

rtems_task_priority
rtems_bsd_get_task_priority(const char *name)
{

(void)name;
return (100);
}

size_t
rtems_bsd_get_task_stack_size(const char *name)
{

(void)name;
return 8 * 1024;
}
1 change: 1 addition & 0 deletions libgrisp/src/init_wpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>

#include <machine/rtems-bsd-commands.h>
Expand Down
2 changes: 1 addition & 1 deletion rtems
Submodule rtems updated from 8b5a80 to 7a1934
2 changes: 1 addition & 1 deletion rtems-libbsd
Submodule rtems-libbsd updated from ef5d53 to eb1d30
2 changes: 1 addition & 1 deletion rtems-source-builder
Submodule rtems-source-builder updated from 8ee4e8 to 9c825f