Show older

And still hangs when transmits Packets ... Chaos Magic 🤔

Something spooky about GPIO Interrupts 🤔 ... Let's disconnect SX1276 pins DIO1 to DIO3 ... And connect DIO0 to my fav Blue LED (GPIO 11)

github.com/lupyuen/bl_iot_sdk/

GPIO Interrupts hanging could be due to the way we handle multiple GPIO Interrupts ... Let's revisit this when we can trigger multiple GPIO Interrupts from SX1276

github.com/lupyuen/bl_iot_sdk/

Now that can handle Packet Received Interrupt ... Let's defer the LoRa Packet Processing from the Interrupt Handler to the Application Task ... How shall we do this in FreeRTOS? 🤔

github.com/lupyuen/bl_iot_sdk/

Shall we teach Multitasking with NimBLE Porting Layer? 1️⃣ Looks easier than FreeRTOS 2️⃣ It's portable to FreeRTOS, Mynewt, NuttX and RIOT OS 🤔

lupyuen.github.io/pinetime-rus

Our Build, Flash and Run Firmware script generates the Disassembly ... Let's track down the address of the RISC-V Exception

github.com/lupyuen/bl_iot_sdk/

Exception happened because we passed a pointer to a stack object ... Which gets used by the Interrupt Handler 😲 ... This works OK in the original Mynewt code, but not for BL602

gist.github.com/lupyuen/1539f9

Reference Manual mentions "GPIO_INT_CLR" but the address is undefined in the doc ... Methinks a chunk of addresses are missing from the doc 🤔

github.com/bouffalolab/bl_docs

shows Stack Trace when CONFIG_ENABLE_FP=1 ... But the addresses don't make sense ... They belong to the code that's dumping the Stack Trace 🤔

github.com/lupyuen/bl_iot_sdk/

Oops needs us to "make clean ; make" to fix up the Stack Frame Pointers ... Now BL602 Stack Trace points to the "ebreak" instruction ... Which belongs to the Exception Handler 🙄

github.com/lupyuen/bl_iot_sdk/

Below the Exception Handler Stack ... Is another Stack! ... Does this Stack contain the Stack Trace that we need? 🤔

gist.github.com/lupyuen/5ddbcd

Answer: "radio_events" contains Undefined Fields ... Because it was allocated on the Stack! Lesson Learnt: ALWAYS Init Stack Variables! 🙏

github.com/apache/mynewt-core/

Back to our Stack Trace ... Yep the Correct Stack Trace is indeed lurking behind our (unhelpful) Exception Stack Trace ... How shall we show the Correct Stack Trace beyond the Emptiness? 🤔

gist.github.com/lupyuen/5ddbcd

To conserve battery power, Sensors don't always listen for incoming packets ... They listen for a few seconds then go back to sleep. 😴 LoRa Receive Timeout is the last thing we shall implement for

github.com/lupyuen/bl_iot_sdk/

Driver creates hundreds of SPI DMA Requests ... Each request reads / writes only ONE byte! 🙄 ... Note to future self: Combine the SPI DMA Requests

github.com/lupyuen/bl_iot_sdk/

@PINE64 receiving Packets from RAKwireless ... All shall be explained in this article. Thanks for reading this looong thread 🙏

lupyuen.github.io/articles/lor

@lupyuen wow, that is some crappy implementation by the sound of it! Honestly I am surprised, usually the low-level uC people (the ones working with assembly and C) tend to do a way better job than that.

@freemo Haha ahem ... I ported this LoRa driver from Mynewt OS. The driver was designed for platforms without DMA.

Since we support DMA on BL602, we can do better ... But the driver needs to be redesigned.

@lupyuen Well if its just a hacked together port and not a write from scratch then at least it meakes sense why.. I was worried it was intentional or written from scratch and just poor design.

@lupyuen
What hw part is being talked to over said dma? Does order of dma reads matter? Can you cache requests issue dma read burst and send result asynchronously etc or per queue keeping order? We had similar problem in nokia on radiomodules i think. Dont remember exact solution though.

@PawelK I ported the driver from Mynewt OS to BL602.

Since I don't have the time to redesign the driver and do a thorough regression test ... We'll have to live with this inefficiency for now.

@lupyuen
Can you let me peek at source before port and after port? Curious. Not strong in dma but curious of it.

@PawelK Original LoRa SX1276 Driver for Mynewt OS:

github.com/apache/mynewt-core/

Ported to BL602:

github.com/lupyuen/bl_iot_sdk/

The original code calls "hal_spi_tx_val", which is a Mynewt SPI Function that transfers 1 byte over SPI. It's clearly not designed for DMA.

Show newer
Show newer
Show newer

@lupyuen
Yes uninit vars suck. Llvm/clang autowarns or can error on this. Has great static checker too and plenty of warnings etc.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.