Skip to content
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

nimble/porting: sync with core #872

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

KKopyscinski
Copy link
Contributor

Synchronization of state with core repository.

This solves #858

@KKopyscinski KKopyscinski force-pushed the porting-sync branch 4 times, most recently from 50d27be to 03730ab Compare October 12, 2020 06:48
@KKopyscinski
Copy link
Contributor Author

linux_blemesh example isn't compiling due to lack of mesh porting (converting uint to * void is not portable)

@KKopyscinski
Copy link
Contributor Author

Added some type definitions in os_trace_api.h to avoid including hardware dependent files.

@andrzej-kaczmarek
Copy link
Contributor

Added some type definitions in os_trace_api.h to avoid including hardware dependent files.

so if this has to be out of sync anyway, then just strip unused defs from there and leave only what's needed instead of adding even more stuff.

@KKopyscinski
Copy link
Contributor Author

Added some type definitions in os_trace_api.h to avoid including hardware dependent files.

so if this has to be out of sync anyway, then just strip unused defs from there and leave only what's needed instead of adding even more stuff.

Ok, makes sense to me. Done.

* chain.
*/
uint16_t os_mbuf_len(const struct os_mbuf *om);
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bogus comment start

This isn't in core... did you copy code fragments manually instead of simply copying whole file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied whole contents of corresponding files, except of includes and adjusted some defined values to match.

This method is here:
https://github.com/apache/mynewt-core/blob/c5d9068cd472f32f0afd89594038a188d9ddf50d/kernel/os/include/os/os_mbuf.h#L429

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so before copying I was checking diff, to see what is added and what might cause errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by this I mean extra /** added after function declaration, which is causing issues due to double comment start (aka comment in comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I remember now: I was indeed copying fragments indicated by diff - to prevent conflict between types, for example ble_npl_event and os_eventq. So yes, this is caused by copying fragments.

Synchronization of state with core repository.
@apache-mynewt-bot
Copy link

Style check summary

Our coding style is here!

porting/nimble/include/os/queue.h

@@ -111,18 +111,18 @@
 /*
  * Singly-linked List declarations.
  */
-#define	SLIST_HEAD(name, type)                          \
-struct name {                                           \
-    struct type *slh_first;	/* first element */         \
-}
-
-#define	SLIST_HEAD_INITIALIZER(head)                    \
+#define SLIST_HEAD(name, type)                          \
+    struct name {                                           \
+        struct type *slh_first; /* first element */         \
+    }
+
+#define SLIST_HEAD_INITIALIZER(head)                    \
     { NULL }
 
-#define	SLIST_ENTRY(type)                               \
-struct {                                                \
-    struct type *sle_next;  /* next element */          \
-}
+#define SLIST_ENTRY(type)                               \
+    struct {                                                \
+        struct type *sle_next; /* next element */          \
+    }
 
 /*
  * Singly-linked List functions.

porting/nimble/src/hal_timer.c

@@ -75,34 +75,34 @@
 
 static const struct nrf52_hal_timer *nrf52_hal_timers[NRF52_HAL_TIMER_MAX] = {
 #if MYNEWT_VAL(TIMER_0)
-        &nrf52_hal_timer0,
+    &nrf52_hal_timer0,
 #else
-        NULL,
+    NULL,
 #endif
 #if MYNEWT_VAL(TIMER_1)
-        &nrf52_hal_timer1,
+    &nrf52_hal_timer1,
 #else
-        NULL,
+    NULL,
 #endif
 #if MYNEWT_VAL(TIMER_2)
-        &nrf52_hal_timer2,
+    &nrf52_hal_timer2,
 #else
-        NULL,
+    NULL,
 #endif
 #if MYNEWT_VAL(TIMER_3)
-        &nrf52_hal_timer3,
+    &nrf52_hal_timer3,
 #else
-        NULL,
+    NULL,
 #endif
 #if MYNEWT_VAL(TIMER_4)
-        &nrf52_hal_timer4,
+    &nrf52_hal_timer4,
 #else
-        NULL,
+    NULL,
 #endif
 #if MYNEWT_VAL(TIMER_5)
-        &nrf52_hal_timer5
+    &nrf52_hal_timer5
 #else
-        NULL
+    NULL
 #endif
 };
 
@@ -481,51 +481,51 @@
 
     switch (timer_num) {
 #if MYNEWT_VAL(TIMER_0)
-        case 0:
+    case 0:
         irq_num = TIMER0_IRQn;
         hwtimer = NRF_TIMER0;
         irq_isr = nrf52_timer0_irq_handler;
         break;
 #endif
 #if MYNEWT_VAL(TIMER_1)
-        case 1:
+    case 1:
         irq_num = TIMER1_IRQn;
         hwtimer = NRF_TIMER1;
         irq_isr = nrf52_timer1_irq_handler;
         break;
 #endif
 #if MYNEWT_VAL(TIMER_2)
-        case 2:
+    case 2:
         irq_num = TIMER2_IRQn;
         hwtimer = NRF_TIMER2;
         irq_isr = nrf52_timer2_irq_handler;
         break;
 #endif
 #if MYNEWT_VAL(TIMER_3)
-        case 3:
+    case 3:
         irq_num = TIMER3_IRQn;
         hwtimer = NRF_TIMER3;
         irq_isr = nrf52_timer3_irq_handler;
         break;
 #endif
 #if MYNEWT_VAL(TIMER_4)
-        case 4:
+    case 4:
         irq_num = TIMER4_IRQn;
         hwtimer = NRF_TIMER4;
         irq_isr = nrf52_timer4_irq_handler;
         break;
 #endif
 #if MYNEWT_VAL(TIMER_5)
-        case 5:
-            irq_num = RTC0_IRQn;
-            hwtimer = NRF_RTC0;
-            irq_isr = nrf52_timer5_irq_handler;
-            bsptimer->tmr_rtc = 1;
-            break;
-#endif
-        default:
-            hwtimer = NULL;
-            break;
+    case 5:
+        irq_num = RTC0_IRQn;
+        hwtimer = NRF_RTC0;
+        irq_isr = nrf52_timer5_irq_handler;
+        bsptimer->tmr_rtc = 1;
+        break;
+#endif
+    default:
+        hwtimer = NULL;
+        break;
     }
 
     if (hwtimer == NULL) {
@@ -543,7 +543,7 @@
 
     return 0;
 
-    err:
+err:
     return rc;
 }
 
@@ -675,7 +675,7 @@
 
     return 0;
 
-    err:
+err:
     return rc;
 }
 
@@ -720,7 +720,7 @@
 #endif
     OS_EXIT_CRITICAL(sr);
 
-    err:
+err:
     return rc;
 }
 
@@ -745,7 +745,7 @@
     resolution = 1000000000 / bsptimer->tmr_freq;
     return resolution;
 
-    err:
+err:
     rc = 0;
     return rc;
 }
@@ -776,7 +776,7 @@
     return tcntr;
 
     /* Assert here since there is no invalid return code */
-    err:
+err:
     assert(0);
     rc = 0;
     return rc;
@@ -830,7 +830,7 @@
 
     rc = 0;
 
-    err:
+err:
     return rc;
 }
 

@KKopyscinski
Copy link
Contributor Author

@sjanc Could you review this? I rebased it onto master, copied the files again and checked for confilcts, all travis checks for porting are passing now

@KKopyscinski KKopyscinski merged commit ab53154 into apache:master Feb 16, 2021
@btashton
Copy link

Just noticed that this broke our CI in NuttX do to a bad cast point-to-int of different size:

/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c: In function 'os_mbuf_get':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:247:46: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  247 |     os_trace_api_u32x2(OS_TRACE_ID_MBUF_GET, (uint32_t)omp,
      |                                              ^
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:268:48: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  268 |     os_trace_api_ret_u32(OS_TRACE_ID_MBUF_GET, (uint32_t)om);
      |                                                ^
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c: In function 'os_mbuf_get_pkthdr':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:279:53: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  279 |     os_trace_api_u32x2(OS_TRACE_ID_MBUF_GET_PKTHDR, (uint32_t)omp,
      |                                                     ^
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:301:55: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  301 |     os_trace_api_ret_u32(OS_TRACE_ID_MBUF_GET_PKTHDR, (uint32_t)om);
      |                                                       ^
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c: In function 'os_mbuf_free':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:310:45: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  310 |     os_trace_api_u32(OS_TRACE_ID_MBUF_FREE, (uint32_t)om);
      |                                             ^
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c: In function 'os_mbuf_free_chain':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.c:332:51: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  332 |     os_trace_api_u32(OS_TRACE_ID_MBUF_FREE_CHAIN, (uint32_t)om);
      |                                                   ^
cc1: all warnings being treated as errors
make[3]: *** [/github/workspace/sources/apps/Application.mk:134: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mbuf.github.workspace.sources.apps.wireless.bluetooth.nimble.o] Error 1
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c: In function 'os_memblock_get':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:336:48: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  336 |     os_trace_api_u32(OS_TRACE_ID_MEMBLOCK_GET, (uint32_t)mp);
      |                                                ^
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:364:52: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  364 |     os_trace_api_ret_u32(OS_TRACE_ID_MEMBLOCK_GET, (uint32_t)block);
      |                                                    ^
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c: In function 'os_memblock_put_from_cb':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:375:58: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  375 |     os_trace_api_u32x2(OS_TRACE_ID_MEMBLOCK_PUT_FROM_CB, (uint32_t)mp,
      |                                                          ^
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:376:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  376 |                        (uint32_t)block_addr);
      |                        ^
/github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c: In function 'os_memblock_put':
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:408:50: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  408 |     os_trace_api_u32x2(OS_TRACE_ID_MEMBLOCK_PUT, (uint32_t)mp,
      |                                                  ^
Error: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.c:409:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  409 |                        (uint32_t)block_addr);
      |                        ^
cc1: all warnings being treated as errors
make[3]: *** [/github/workspace/sources/apps/Application.mk:134: /github/workspace/sources/apps/wireless/bluetooth/nimble/mynewt-nimble/porting/nimble/src/os_mempool.github.workspace.sources.apps.wireless.bluetooth.nimble.o] Error 1
make[3]: Target 'all' not remade because of errors.
make[2]: *** [Makefile:59: /github/workspace/sources/apps/wireless/bluetooth/nimble_all] Error 2
make[2]: Target '/github/workspace/sources/apps/libapps.a' not remade because of errors.
make[1]: *** [Makefile:53: all] Error 2
make: *** [tools/LibTargets.mk:225: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 267: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory

@KKopyscinski
Copy link
Contributor Author

@btashton #915 should fix this.
Also, to make sure code won't broke like that in the future, you can add target to https://github.com/JuulLabs-OSS/mynewt-travis-ci

danielgjackson added a commit to cueband/InfiniTime that referenced this pull request Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants