drivers/sx126x: fix hardware detection on init#21850
Conversation
|
Note: I have not yet tested the change, so please wait for hitting the green button |
Yes.
Also yes, when I dont have the shield connected. But also that is the bahavior for me on master. Did you get the assert trigger? |
Yes, in the DFT Communication board when no Antenna Board is connected. There seems to be something slightly pulling up the CIPO (aka MISO) line. You should be able to reproduce by adding 100 K resistor between VCC and CIPO. The assert is quite late in the boot: The init worked just fine without the LoRa chip connected, but GNRC than triggered an assertion because the netdev type was reported as unknown, which was not explicitly handled in a |
|
Ok, when it fixes it in the com board. CI no longer accepts the commits from the "Commit suggestion" button. |
|
Let's not hit merge just yet. I was too busy with the other project to confirm it does fix the issue just yet. |
|
I can confirm that the device presence test now works. The issue is also not specific to one instance of the DFT communication board, but happens reliable on two instances. So I'd say it is an issue we might see on other hardware as well. |
2c2c6a8 to
64b307e
Compare
|
Oh, shit. It appears that the LoRa chips on the antenna boards default to GFSK and not to LoRa after reset :/ |
|
With this test it now works reliably for me. Better would be if there would be some vendor ID or device ID in the register map that we could read out and check. But I couldn't find something like that in the data sheet. |
I have been looking for this before. Because I could not find it, the current state was good enough for me since it worked on the board I tested. If the default was GFSK, why did it show up for me on the adafruit board which has the same LoRa chip? typedef enum sx126x_pkt_types_e
{
SX126X_PKT_TYPE_GFSK = 0x00,
SX126X_PKT_TYPE_LORA = 0x01,
SX126X_PKT_TYPE_BPSK = 0x02,
SX126X_PKT_TYPE_LR_FHSS = 0x03,
} sx126x_pkt_type_t;Anyway ... anything |
When the CIPO line is pulled high, the driver will initialize even when no chip is connected. This adds a read of the configured modulation, which should be LoRa after a reset (even when configured to e.g. GFSK prior). The packet type contains both one and zero bits, so chance to read the only accepted byte from a floating SPI bus is relatively low. Co-authored-by: crasbe <[email protected]>
No network stack in RIOT is prepared for hardware to change its device type at runtime. Especially the unknown network device is just not handled and causes assertions to blow. Instead, the driver now just returns to be a LoRa radio regardless of configured modulation.
23faf47 to
f16ceb3
Compare
OK, then let's go with that. It did work reliably for me on two different systems. |
Contribution description
When the CIPO line is pulled high, the driver will initialize even when
no chip is connected. This adds a read of the configured modulation,
which should be LoRa after a reset (even when configured to e.g. GFSK
prior). The packet type contains both one and zero bits, so chance
to read the only accepted byte from a floating SPI bus is relatively
low.
Testing procedure
Issues/PRs references
None