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

SX126x with address filtering always reports wrong CRC #1268

Open
jgromes opened this issue Oct 12, 2024 · 7 comments
Open

SX126x with address filtering always reports wrong CRC #1268

jgromes opened this issue Oct 12, 2024 · 7 comments
Labels
bug Something isn't working help wanted If you're looking to help with RadioLib development, these are the issues to work on

Comments

@jgromes
Copy link
Owner

jgromes commented Oct 12, 2024

Describe the bug
After node or broadcast address filtering on SX126x is enabled, the CRC error IRQ flag will always be set (even if CRC is disabled). This leads to RadioLib always reporting CRC error. The data retrieved also seems to be garbage.

From what I can tell, the CRC should be calculated correctly, at least when transmitting. With address enabled (and set to 0x36, char '6' to easily see it in text prints), I was able to verify that the CRC calculated does match 16-bit CCITT CRC with inversion of the result (radio.setCRC(2, 0x1D0F, 0x1021, true)). Online calculator shows for the input 0x11 0x36 0x48 0x65 0x6c 0x6c 0x6f 0x20 0x57 0x6f 0x72 0x6c 0x64 0x21 0x20 0x23 0x31 0x31 the result 0xC03E, which matches with SDR:

Screenshot_110

So it should be the case that CRC is calculated over the payload length, address and payload itself, as shown in the datasheet. However, for some reason, this breaks on receiving.

Screenshot_111

Google search does not return much info, it seems like the node/broadcast adress filtering was never used much on SX126x. Errata doesn't show anything in this regard.

Workaround
Workaround is to not use the built-in node or broadcast filtering on SX126x. Instead, this can be implemented by the user, as data transmitted from other FSK modules with node address (e.g. SX127x) is received correctly. The address byte will be the first byte read from FIFO. With this workaround, CRC checks pass (transmitted from SX127x with target node set to 0x36):

Data[20]: 6Hello World! #20
Packet RSSI: -50.00 dBm
Inst. RSSI:  -109.00 dBm
LoRa SNR:    -20.00 dB

To Reproduce

// add to FSK transmit example after begin
radio.setNodeAddress('6');
radio.setBroadcastAddress('7'); // broadcast address also breaks CRC
radio.setCRC(0); // disabling CRC does not seem to help

Expected behavior
Enabling address filtering shall not break CRC functionality.

Additional info

  • MCU: RPi 3B+
  • Wireless module type: SX126x (Waveshare LoRaWAN hat)
  • Library version 7.0.2
@jgromes jgromes added bug Something isn't working help wanted If you're looking to help with RadioLib development, these are the issues to work on labels Oct 12, 2024
@jgromes
Copy link
Owner Author

jgromes commented Oct 12, 2024

While debugging this, I also fixed two other problems with SX127x and SX126x FSK addresses, however, neither is the root cause of this issue.

@ClaudiusVi
Copy link

I've noticed similar issues and would like to share my experience. About three months ago, I first observed problems with Vollgo SX1262 modules. I then replaced some of them with G-NiceRF LoRa modules, and everything worked fine. In a delivery six weeks ago, G-NiceRF modules were included on the boards, and again, there were no issues.

However, with the most recent batch, which also included G-NiceRF modules, I suddenly encountered the problem that no reception occurs at all. Right now, I have no idea what the cause could be. I've re-checked the old Rev9 and Rev8 boards without finding any clear reason for this. It seems like there's some inexplicable mechanism causing the issue, and currently, I'm completely in the dark regarding this random failure. There are over 30 boards lying around, and none of them are receiving anymore.

I'm using an ESP32-S3 WROOM without PSRAM.

Not sure if this helps, but I'd appreciate any hints that could lead me in the right direction.

@jgromes
Copy link
Owner Author

jgromes commented Nov 7, 2024

@ClaudiusVi are you sure this is the same problem? The original issue only appears in FSK mode with address filtering, did you also use that? What you're describing seems more like a hardware/manufacturing issue to me.

@ClaudiusVi
Copy link

ClaudiusVi commented Nov 7, 2024 via email

@ClaudiusVi
Copy link

Hi @jgromes,

We checked today and found that the issue only occurs with version 7.10. The problem is not present in version 7.02.

During development, we switched from the SX1276 to the SX1262 because the SX1262 is newer and offers more features. After comparing the datasheets, this seemed like a better choice, especially because the SX1276 caused major issues on the Raspberry Pi 5. The I/O chip on the Raspberry Pi 5 runs over PCI, which led to problems, so we switched to the SX1262.

We checked the registers and found the following: Both chips offer the capability to configure an 8-byte sync word, but the specific register addresses differ. Here is a table of the registers for the 8-byte sync word on the SX1262 and SX1276:

Byte SX1262 Register Address SX1276 Register Address
Byte 1 0x06C0 0x28
Byte 2 0x06C1 0x29
Byte 3 0x06C2 0x2A
Byte 4 0x06C3 0x2B
Byte 5 0x06C4 0x2C
Byte 6 0x06C5 0x2D
Byte 7 0x06C6 0x2E
Byte 8 0x06C7 0x2F

It seems that there is a small bug somewhere in the code of version 7.10 that is causing this issue. Hopefully, this information helps to locate the bug.

@ClaudiusVi
Copy link

P.S.: We tested the modules with different SPI controllers: SPI, SPI2 (commonly referred to as HSPI), and SPI3 (commonly referred to as VSPI). The default controller used in our program is SPI2 (HSPI), but we also tried using SPI directly.

@jgromes
Copy link
Owner Author

jgromes commented Nov 8, 2024

@ClaudiusVi I think you are describing a different issue. The original problem has no relation to sync word; only to address filtering and CRC being enabled. Please open a new issue for this, including all the information in the issue template.

I would also like to point out that the SPI interface of SX127x and SX126x series is completely different; most SX126x commands are not sent via SPI registers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted If you're looking to help with RadioLib development, these are the issues to work on
Projects
None yet
Development

No branches or pull requests

2 participants