博文

Add wpa_supplicant_fork command on RTEMS-libbsd

After port the WPA on RTEMS-libbsd. We can use wpa_supplicant in RTEMS shell, but there is a bug, but when config WPA via "wpa_supplicant", we can't use shell command and other thread. So we need create a command (such as wpa_supplicant_forking) to start wpa_supplicant in a new thread. 1. Add wpa_supplicant_fork command file which define the wpa_supplicant_fork command struct. rtems-bsd-shell-wpa_supplicant_fork.c +/* + * Copyright (c) 2017 Sichen Zhao.  All rights reserved. + * + *  <zsc19940506@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *    notice, this list of conditions and the following disclaimer in the

Port WPA supplicant to RTEMS-libbsd

Last blog post, i write about how to import wpa from FreeBSD. This blog post, i will introduct how to port WPA to RTEMS-libbsd. 1.RTEMS doesn't support the PID and daemonize, so we need modify the os_unix.c. a). Add the unistd.h  #include <mach/mach_time.h>  #endif /* __MACH__ */ +#ifdef __rtems__ +#include <unistd.h> +#endif /* __rtems__ */ +  #include "os.h"  #include "common.h" b). Return -1 for os_daemonize function. We add defined(__rtems__) in os_daemonize funtion  int os_daemonize(const char *pid_file)  { -#if defined(__uClinux__) || defined(__sun__) +#if defined(__uClinux__) || defined(__sun__) || defined(__rtems__)   return -1;  #else /* defined(__uClinux__) || defined(__sun__) */  #ifdef __FreeBSD__ 2. RTEMS doesn't support the urandom, which is widely used in FreeBSD and Linux to generate the random number. So we need replace it with getentropy function, which is supported in RTEMS. os_unix.c int o

Import WPA from FreeBSD

We need WPA source files to compile and implement the wpa_supplicant. We can get the wpa source code from their web site: https://w1.fi/wpa_supplicant/ For RTEMS-libbsd, we can directly import it from FreeBSD. 1.Firstly, we need add these imported files in libbsd.py. We create a new module named :usr_sbin_wpa_supplicant, and add files in this module: +# /usr/sbin/wpa_supplicant +# +def usr_sbin_wpa_supplicant(mm): +    mod = builder.Module('usr_sbin_wpa_supplicant') +    mod.addUserSpaceHeaderFiles( +        [ +            'contrib/wpa/wpa_supplicant/ap.h', +            'contrib/wpa/wpa_supplicant/blacklist.h', +            'contrib/wpa/wpa_supplicant/bss.h', +            'contrib/wpa/wpa_supplicant/config.h', +            'contrib/wpa/wpa_supplicant/config_ssid.h', +            'contrib/wpa/wpa_supplicant/ctrl_iface.h', +            'contrib/wpa/wpa_supplicant/driver_i.h', +            'contrib/wpa

Add openssl lib support for WPA on RTEMS-libbsd

The WPA encrypted WiFi need openssl lib support. So we need port openssl from FreeBSD to RTEMS-libbsd. 1. Add openssl lib files in libbsd.py +# /crypto/openssl  +#  +def crypto_openssl(mm):  +    mod = builder.Module('crypto_openssl')  +    mod.addUserSpaceHeaderFiles(  +        [  +            'crypto/openssl/engines/e_cswift_err.h',  +            'crypto/openssl/engines/e_aep_err.h',  +            'crypto/openssl/engines/e_gmp_err.h',  +            'crypto/openssl/engines/ccgost/gost2001_keyx.h',  +            'crypto/openssl/engines/ccgost/e_gost_err.h',  +            'crypto/openssl/engines/ccgost/gost_params.h',  +            'crypto/openssl/engines/ccgost/gost_lcl.h',  +            'crypto/openssl/engines/ccgost/gost89.h', ...... As the number of openssl files is too large, we do not expand in detail. By the way, there are some files which shouldn't be compiled. so for these files w

Add Copy headers support for RTEMS-libbsd(Christian Mauderer's work)

When i import some files from FreeBSD to RTEMS-libbsd, there are a issues: where a header is installed into a directory with a different name then it's source directory. In that case, the build might fail because the header is not found. One example would be the <openssl/opensslv.h>. The source for this file is in freebsd/crypto/openssl/ crypto/opensslv.h. So for this bug, my mentor Christian Mauderer fix it by copy these files in a temporary catalog. 1. Add a temporary catalog in builder.py def includes():       return ['-Irtemsbsd/include',  +            '-Ilibbsd_build/include',               '-Ifreebsd/sys',               '-Ifreebsd/sys/contrib/pf',               '-Ifreebsd/sys/net', 2. Add the copy method in waf_generator.py # # Add a copy rule for all headers where the install path and the source # path are not the same. # self .add( ' # copy headers if necessary ' ) headerPaths = builder.head

Add WEP encrypted WiFi support for RTEMS-libbsd on BBB BSP

After add the rtl8188eu WiFi chip support on RTEMS, We need add the encrypted WiFi support for RTEMS-libbsd. WEP is a kind of encrypted WiFi which is easier to implement then WPA. So let us first implement the WEP. How to add WEP support for RTEMS-libbsd 1. Add the WEP module suppport in nexus-devices.h We need the encryption algorithm support for WEP, so add the wlan_wep module in nexus-devices.h +SYSINIT_MODULE_REFERENCE(wlan_wep); 2. Add the encrypted module support in rtems-kernel-init.c The crypto module not support in kernel-init.c. So we need add this support: diff --git a/rtemsbsd/rtems/rtems-kernel-init.c b/rtemsbsd/rtems/rtems-kernel-init.c index 594e1ba..4138bc1 100644 --- a/ rtemsbsd/rtems/rtems-kernel-init.c +++ b/ rtemsbsd/rtems/rtems-kernel-init.c @@ -72,6 +72,8 @@ typedef void (*ratectl_modevent)(int); RTEMS_BSD_DEFINE_SET(ratectl_set, ratectl_modevent); typedef void (*scanner_modevent)(int); RTEMS_BSD_DEFINE_SET(scanner_set, scanner_mode

Add USB dongle rtl8188eu support for RTEMS-libbsd on BBB BSP

After add the USB support for RTEMS-libbsd on Beaglebone Black BSP. The next step is to add the USB dongle driver support, i choose the rtl8188eu chip as my USB WiFi dongle. So how to add rtl8188eu driver support for RTEMS-libbsd? 1. Add rtl8188eu driver firmware This step is described in another blog post: RTEMS-libbsd generates drive device firmware  2. Add module support in nexus-devices.h Tell rtems which module support  we need for USB dongle.  a. Add rtwn on uhub SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub); b. Add rtl8188eu firmware on RTEMS SYSINIT_REFERENCE(rtwn_rtl8188eufw); So, in summary, we need add these code in nexus-devices.h diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h index 09a4cc3..c3e5336 100644 --- a/ rtemsbsd/include/bsp/nexus-devices.h +++ b/ rtemsbsd/include/bsp/nexus-devices.h @@ -56,6 +56,11 @@ SYSINIT_DRIVER_REFERENCE(ti_scm, simplebus); SYSINIT_DRIVER_REFERENCE(am335x_