-
Notifications
You must be signed in to change notification settings - Fork 399
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
[linux] initial port and osal additions. #4
Conversation
- Created linux port of os_task, os_sem, os_mutex, os_callout, etc. - Added unit tests for osal. - Mods to support pointer alignment on 64-bit architectures. - Fixes to ble_hci_sock to support linux port - Fallback to BLE 4.2 or 4.0 controllers when 5.0 features not available. - Added Linux instructions to README.
porting/common/src/sysinit/sysinit.c
Outdated
@@ -34,7 +36,8 @@ sysinit_dflt_panic_cb(const char *file, int line, const char *func, | |||
} | |||
#endif | |||
|
|||
__assert_func(file, line, func, expr); | |||
__assert_fail(msg, file, line, func); | |||
//__assert_func(file, line, func, expr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a known conflict between FreeRTOS and Linux that needs to be resolved before merging.
@andrzej-kaczmarek are we good to merge this? |
@sterlinghughes I need to update porting layer and push it to latest official master - I'm on it. Then this can be put on top, perhaps after some changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
some comments on what needs to be updated before this could go in:
- in general license stuff needs to be fixed
- code should be C
- there seems to be some not needed SDK code that should be removed
- this is a bit less important but code should follow Mynewt coding style (also for comments /**/ instead of C++//)
I put some comments inline in places I spotted, but if I miss anything similar it should also be fixed.
# | ||
# Licensees are granted free, non-transferable use of the information. NO | ||
# WARRANTY of ANY KIND is provided. This heading must NOT be removed from | ||
# the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be checked if this license is apache approved.
@@ -0,0 +1,698 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
miising license
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed anyway for host?
void os_atomic_end() | ||
{ | ||
pthread_mutex_unlock(&s_mutex); | ||
pthread_cond_signal(&s_cond); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this conditional is needed? there seems to be no pthread_cond_wait() called anywhere for s_cond
os_error_t | ||
os_mutex_release(struct os_mutex *mu) | ||
{ | ||
if (!mu) return OS_INVALID_PARM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding style
os_error_t | ||
os_mutex_pend(struct os_mutex *mu, uint32_t timeout) | ||
{ | ||
if (!mu) return OS_INVALID_PARM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding style
|
||
assert(&mu->lock); | ||
|
||
struct timespec wait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variables should be defined at beginning of function
os_error_t | ||
os_sem_init(struct os_sem *sem, uint16_t tokens) | ||
{ | ||
if (!sem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style
@@ -0,0 +1,26 @@ | |||
#ifndef _OS_SEM_H_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license
#include <pthread.h> | ||
|
||
pthread_mutex_t s_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; | ||
pthread_cond_t s_cond = PTHREAD_COND_INITIALIZER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be static?
Usurped by #90. |
It is possible that scheduler already fired and aux data is NULL so we should unref it only if scheduler item was removed. ble_ll_scan_aux_data_unref (aux_data=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:1079 1079 BLE_LL_ASSERT(aux_data); (gdb) bt #0 ble_ll_scan_aux_data_unref (aux_data=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:1079 apache#1 0x0001f732 in ble_ll_scan_rx_pkt_in_on_aux (pdu_type=<optimized out>, om=0x2000d6f8 <os_msys_1_data>, hdr=0x2000d710 <os_msys_1_data+24>, addrd=addrd@entry=0x20004ecc <g_ble_ll_stack+404>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:3156 apache#2 0x0002010e in ble_ll_scan_rx_pkt_in (ptype=ptype@entry=7 '\a', om=om@entry=0x2000d6f8 <os_msys_1_data>, hdr=hdr@entry=0x2000d710 <os_msys_1_data+24>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:3198 apache#3 0x0001299e in ble_ll_rx_pkt_in () at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:837 apache#4 0x000129de in ble_ll_event_rx_pkt (ev=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:1164 apache#5 0x00012830 in ble_npl_event_run (ev=<optimized out>) at repos/apache-mynewt-nimble/porting/npl/mynewt/include/nimble/nimble_npl_os.h:116 apache#6 ble_ll_task (arg=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:1214 apache#7 0x00038e9c in nrf52_clock_hfxo_release () at repos/apache-mynewt-core/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h:37 apache#8 0x00000000 in ?? ()
It is possible that scheduler already fired and aux data is NULL so we should unref it only if scheduler item was removed. ble_ll_scan_aux_data_unref (aux_data=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:1079 1079 BLE_LL_ASSERT(aux_data); (gdb) bt #0 ble_ll_scan_aux_data_unref (aux_data=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:1079 #1 0x0001f732 in ble_ll_scan_rx_pkt_in_on_aux (pdu_type=<optimized out>, om=0x2000d6f8 <os_msys_1_data>, hdr=0x2000d710 <os_msys_1_data+24>, addrd=addrd@entry=0x20004ecc <g_ble_ll_stack+404>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:3156 #2 0x0002010e in ble_ll_scan_rx_pkt_in (ptype=ptype@entry=7 '\a', om=om@entry=0x2000d6f8 <os_msys_1_data>, hdr=hdr@entry=0x2000d710 <os_msys_1_data+24>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:3198 #3 0x0001299e in ble_ll_rx_pkt_in () at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:837 #4 0x000129de in ble_ll_event_rx_pkt (ev=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:1164 #5 0x00012830 in ble_npl_event_run (ev=<optimized out>) at repos/apache-mynewt-nimble/porting/npl/mynewt/include/nimble/nimble_npl_os.h:116 #6 ble_ll_task (arg=<optimized out>) at repos/apache-mynewt-nimble/nimble/controller/src/ble_ll.c:1214 #7 0x00038e9c in nrf52_clock_hfxo_release () at repos/apache-mynewt-core/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h:37 #8 0x00000000 in ?? ()
Tested advertising, scan response, connections and GATT database operations.