Commit Graph

25 Commits

Author SHA1 Message Date
Andrzej Kaczmarek 2de66c2797 babblesim: Fix invalid switch from isr to task
BabbleSim triggers interrupts when exiting from critical section (i.e.
interrupts are unlocked) and then we check for pending context switch.
This can lead to invalid switch from isr to task context before isr has
actually finished:
- interrupts are unlocked
- interrupt is triggered
- isr calls os_* which uses critical section and triggers context switch
  (e.g. os_eventq_put)
- when exiting critical section in isr, we check for pending context
  switch and immediately switch to task context before isr is completed

To fix this we should only perform context switch if exiting from
critical section in task context.
2023-02-27 14:10:20 +01:00
Andrzej Kaczmarek 0a08f6f449 babblesim: Fix os_arch_in_isr 2023-02-27 14:10:20 +01:00
Andrzej Kaczmarek 35583ac325 babblesim: Print script errors to stderr 2022-09-19 11:42:50 +02:00
Andrzej Kaczmarek ce36b50ae5 babblesim: Update dependency to phy 2022-09-19 11:42:50 +02:00
Andrzej Kaczmarek 0b983a52d5 babblesim: Fix blehci target 2022-09-08 11:44:24 +02:00
Andrzej Kaczmarek 886597f223 babblesim: Fix EDTT transport nad target 2022-09-06 14:27:36 +02:00
Andrzej Kaczmarek 5a7f7df964 babblesim: Add syscfg def indicating BabbleSim bsp
Useful for syscfg variants
2022-08-30 13:44:24 +02:00
Andrzej Kaczmarek a7d5ac1148 babblesim: Fix build with latest BabbleSim
irq_sources.h was removed, not needed.
2022-08-30 13:44:24 +02:00
Szymon Janc dc5a32f3b8 nimble/ll: Make LL task stack size configurable
This commit makes LL stack size configurable. Depending on compiler and
platform default value may not be enough. It was reported that on nRF52840
90 words is not enough even if Ext Adv is disabled. To keep things simple
lets just increase default stack size to 120 word for all usecases (with
exception of nRF51 where defults to 96 bytes).
2022-06-27 09:18:24 +02:00
Andrzej Kaczmarek f5a26ab05c babblesim/edtt: Update EDTT transport 2022-03-17 11:48:16 +01:00
Bas van den Berg e2b73b4f32 includes: remove duplicate includes (remove 2nd) 2022-03-08 16:37:32 +01:00
Andrzej Kaczmarek 045c3d19cd babblesim/edtt: Workaround EDTT not consuming cs/cc
It seems that sometimes EDTT can send a command before cs/cc is consumed
by get_event and this triggers an error since cmd buffer is reused for
cs/cc and thus it will be queued as an event on edtt_q_event.

Not sure if this is an EDTT issue/feature or smth on our side, for now
we can workaround this by simply creating a copy of cs/cc which can be
safely enqueued on edtt_q_event waiting to be consumed and freed by
get_event while original cmd buffer is freed as soon as cs/cc is
processed.
2022-03-03 15:04:41 +01:00
Andrzej Kaczmarek 3923f1bb1e babblesim/edtt: Fix le_data_read 2022-03-03 15:04:41 +01:00
Andrzej Kaczmarek 52deeedff1 babblesim/edtt: Handle write bd addr
Some test cases change public address during test so we need to handle
this.
2022-03-03 15:04:41 +01:00
Andrzej Kaczmarek 810ef5e923 babblesim/edtt: Refactor queue handling
This reworks events handling in EDTT.

The "service_events" routine is now handled in separate task which
blocks until new event is put in queue. This is possible since we use
os_eventq to pass events and this means any get from queue will put
task to sleep properly and trigger context switch if necessary.

The blocking edtt_read() will now sleep if not data is available instead
of advancing time machine forward so it does not interfere with timing.
OS_TICKS_PER_SEC was increased to 1024 to have better granularity and
allow ~5ms sleep time for edtt poller task as required.

Also some non-LL code is simplified to use simple calloc/free as it does
not really seem to be cessary to use mempools there, i.e. we just need
some memory block to pass data and it does not really matter how it's
allocated. Also using calloc/free means we will never run out of memory
so no need to check for that.
2022-03-03 15:04:41 +01:00
Andrzej Kaczmarek 811d2a55d1 babblesim: Add command line arg to specify bdaddr
This allows to set public bdaddr using -A or --bdaddr command line
option. Accepted formats are both XX:XX:XX:XX:XX:XX and 0xXXXXXXXXXXXX.
2022-03-03 14:52:34 +01:00
Andrzej Kaczmarek 894d532168 babblesim: Remove sbrk
We do not need it since this works natively with libc.
2022-02-21 22:41:16 +01:00
Magdalena Kasenberg fd3b1466d7 bsim: Add EDTT hci test app
adopted from Zephyr.
2022-02-19 15:02:07 +01:00
Andrzej Kaczmarek a63418cc12 babblesim: Rework sdk package
This moves all external components to separate sdk package. We'll link
both bsim components and nrfx there and setup include paths.
2022-02-17 15:55:41 +01:00
Andrzej Kaczmarek 2332051c61 babblesim: Use pthreads instead of setlongjmp for tasks
This changes tasks handling to native threads instead of setlongjmp()
which resolves issue with calling the setlongjmp() from nested signal
handlers but also simplifies code, makes debugging much easier and can
work nicely with e.g. Valgrind.

Each task is wrapped in a thread and all threads are synchronized on
a global mutex to make sure only one task executes at any time. If
context switch is requested (this is always done via os_sched() in
critical section), a flag is set to indicate pending context switch
which will be handled after exiting from critical setion and handling
all other pending interrupts. This mimics the way it's done on a real
hardware.
2022-02-17 15:55:31 +01:00
Andrzej Kaczmarek b0c69ce9d4 babblesim: Remove local libc
This does not seem to be used anymore.
2022-02-16 15:55:44 +01:00
Andrzej Kaczmarek 1084fdb158 babblesim: Add uart1
This allows to have e.g. console and ble_monitor enabled at the same
time.
2022-02-16 12:45:46 +01:00
Andrzej Kaczmarek 883f953476 babblesim: Add sample targets 2022-02-16 12:29:05 +01:00
Andrzej Kaczmarek 06a19ab940 babblesim: Add hal_flash and hal_hw_id
This allows to run more apps on BabbleSim, e.g. blecent and bleprph.
2022-02-16 12:29:05 +01:00
Magdalena Kasenberg 9abe36cc3c babblesim: Add babblesim pkg
Co-authored-by: Jakub Rotkiewicz <jakub.rotkiewicz@codecoup.pl>
Co-authored-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2022-02-16 09:15:09 +01:00