DeviationTX / deviation

Custom firmware for RC Transmitters
http://www.deviationtx.com
GNU General Public License v3.0
247 stars 153 forks source link

ExpressLRS support #1009

Closed phobos- closed 2 years ago

phobos- commented 3 years ago

This adds the same functionality as ExpressLRS LUA in DeviationTX: https://github.com/ExpressLRS/ExpressLRS/blob/develop/src/lua/ELRS.lua

This code works with ExpressLRS v1.0.0-RC1 onwards. Attached test binaries for Jumper T8SG V2 Plus. Feedback is very much welcome.

(Note - only esp based ExpressLRS tx modules are supported -> -DUART_INVERTED needs to be commented out in user_defines.txt) (Note2 - you need hardware CRSF mod in your radio in order for CRSF to work on the correct pin. Tutorial here: https://www.youtube.com/watch?v=Lr_YRGJl5x8)

deviation-t8sg_v2_plus-v5.0.0-1dc62dc.zip deviation-t8sg_v2-v5.0.0-1dc62dc.zip

Dropsleutel commented 3 years ago

Hi Phobos, I flashed your firmware in my tx, just to have a look. just to mention I have no ESP 2.4ghz, only Frsky R9 I could test for you. R9M module works in via PXX, as protocol it is inverted in deviation. So CRSF output, it need to get inversion option in order to use inverted R9M in the back.

I see that firmware, nr c84450e it is excact same nr, as version i flashed in my Tx 30december2020.

There is no ELRS protocol in the list, but when selecting CRSF protocol, (note no module present in bay), I can see an empty menu, no txt, just yellow line which can be changed 4 positions up/down.

Thanks for all your great help and efforts !! let me know if can help testing

phobos- commented 3 years ago

Hi, thanks for the comment. Hexfet went to hell and back to invert the PXX protocol :) He basically implemented it as a bitbanged PWM: https://github.com/DeviationTX/deviation/blob/master/src/target/tx/devo/common/protocol/pwm.c#L118

For CRSF it is different, it is a hardware UART implementation: https://github.com/DeviationTX/deviation/blob/master/src/protocol/crsf_uart.c#L286

Deviation uses STM32F103RET6 at least for t8sg which I have on hand - that processor is incapable of inverting the UART signal in software, there are additional hardware inverters needed. That would not be the case if an F3 family was used. What could be done from the software side is implementing a software serial communication similar to PXX, but then I don't think we would be able to achieve 400k baudrate speed required by CRSF protocol.

I actually also have an R9M module which I flashed and modded to work with ExpressLRS and Deviation, but I modded it in a way that only allows for one way communication between the module and TX. What it means is you can only send stick information to the module, but you will not receive any communication back, like configuration data, telemetry, etc. If you still want to do the mod you can refer to the short tutorial I posted on RCGroups: https://www.rcgroups.com/forums/showthread.php?3437865-ExpressLRS-DIY-LoRa-based-race-optimized-RC-link-system/page13#post46673237

You will be able to use ExpressLRS gear, but still this Pull Request will not help you, you will see a blank page.

With ESP based module module, you can invert/uninvert the signal on the module side via software. Communication to and from the module would then work as expected, and the CRSF protocol menu should look like this: wx_camera_1618475875234

dat-alex commented 3 years ago

I have recompiled source for the 2400_TX_ESP32_SX1280_E28_viaUART (-DUART_INVERTED be commented out in userdefines.txt) BUT I have not eps32 TX module available to test
SO THIS IS NOT TESTED! I will upload here for someone to test.

DIY_2400_TX_ESP32_SX1280_E28_via_UART.zip

(this way you have not to do the 'dirty work' of installing Visual Studio, settings ,for compiling etc....)

Dropsleutel commented 3 years ago

@Phobos

And what about the R9M, i assume there is an hardware inverter onboard?
Maybe bridging or bypassing it ? Direct feed to the uart pin at R9M cpu?

The resistor mod and alos the temperature issues in R9M were serial comms are affected, maybe we could also get rid off as bot bit of strange issues....

Is there any shematic of R9M or the Happymodel 868?

tonvfx commented 3 years ago

Hey!

This is great. Would it be possible to also do a build for the V2 non-plus? The Carbon T8SG uses that firmware. Thanks!

phobos- commented 3 years ago

@tonvfx

deviation-t8sg_v2-v5.0.0-575ef03.zip

ghost commented 3 years ago

with diy esp-01f+sx127x 868mhz it works fine

https://github.com/ExpressLRS/ExpressLRS/wiki/Building-an-Esp-Rx#custom-esp-900-mhz-rx

tonvfx commented 3 years ago

@tonvfx

deviation-t8sg_v2-v5.0.0-575ef03.zip

That's awesome!! Thanks.. As soon as my module arrives I'll get going with this. Thank you very much!

tonvfx commented 3 years ago

@tonvfx

deviation-t8sg_v2-v5.0.0-575ef03.zip

Got it up and running. Nice one.

ghost commented 3 years ago

Thats great, have you tried on fligth allready? mine fell a loot more reactive...

phobos- commented 3 years ago

I pushed a small bugfix that caused the menus to glitch sometimes. Builds are updated in the first (top) comment. If anyone is interested in a build for a different target - shout here, I'll upload it 😅

jviticofpv commented 3 years ago

Hello my friends...

I would like a little help over here, just to be clear that my Jumper/RadioMaster TX8 (deviation-t8sg_v2) would work ok with Happymodel 2.4Ghz TX/RX combo.

- In order to make it work I must do the next steps??

1- Crossfire pin mod. 2- Flash this firmware ((deviation-t8sg_v2-v5.0.0-1dc62dc.zip)) 3- Update Tx and Rx via WIFI with my pc 4- and that's it??

I would appreciate your help.... not understanding what to do... it's what have me with my purchase on hold.

Thanks in advance from Chile (Venezuelan guy)

Thomas-Lawford commented 3 years ago

Hi, I installed the firmware and completed the hardware mod, but I was wondering: do I need to add a LUA script? -if yes where in the files am I supposed to add it, and where can I get this script?

phobos- commented 3 years ago

@jviticofpv yes, that's it, just remember to flash Happymodel tx with -DUART_INVERTED commented out : #-DUART_INVERTED

phobos- commented 3 years ago

@Thomas-Lawford no need, just follow the same steps as @jviticofpv described in the comment above yours. All config params should be available under CRSF protocol menu.

jviticofpv commented 3 years ago

@jviticofpv yes, that's it, just remember to flash Happymodel tx with -DUART_INVERTED commented out : #-DUART_INVERTED

perfect.... but this part is what I don't understand. I'm sorry to insist, but could you tell me where to get the "how to" about this part.... specially the "comment out part"...

if this means that I must do some coding? (installing coding software)? or just get the happymodel firmware, look for "USER_DEFINES.TXT" file, and comment out with # the line that you mention?

if is like this last part (I'll hope) will. be perfect, because I know that I can do it 😅😅..

thanks again for your help...

phobos- commented 3 years ago

@jviticofpv You can use the ExpressLRS configurator to flash the firmware: https://www.youtube.com/watch?v=XpCvYpyQ4LM&ab_channel=KaijuKaiju https://www.youtube.com/watch?v=wBUamLm51XQ&ab_channel=UAVTechUAVTech

here are two examples, there are many more tutorials on youtube. Finally, if you'll still have trouble with flashing expresslrs stuff you can hop on discord, there are many knowledgable people that can help with specific issues: https://discord.com/invite/dS6ReFY

jviticofpv commented 3 years ago

@jviticofpv You can use the ExpressLRS configurator to flash the firmware: https://www.youtube.com/watch?v=XpCvYpyQ4LM&ab_channel=KaijuKaiju https://www.youtube.com/watch?v=wBUamLm51XQ&ab_channel=UAVTechUAVTech

here are two examples, there are many more tutorials on youtube. Finally, if you'll still have trouble with flashing expresslrs stuff you can hop on discord, there are many knowledgable people that can help with specific issues: https://discord.com/invite/dS6ReFY

thanks so much.... I'm already purchased my expresslrs setup... thanks for clarify my doubts....

tonvfx commented 3 years ago

I pushed a small bugfix that caused the menus to glitch sometimes. Builds are updated in the first (top) comment. If anyone is interested in a build for a different target - shout here, I'll upload it 😅

Hey! I just flashed this to my radio, seemed fine.. except, when I accidentally switched to sbus and back to crsf the menu was gone. I had to load another model, switch off the radio, switch on, reload elrs and it was back. Also, I doesn't look like wifi update is working on MacOs.. Chrome stalls at 17% and then wifi is lost... which brings me to another question, is there a way for me to see what version of expresslrs I'm running on my radio? ("version" in the menu would be nice..)

Thanks for the awesome work!

howels commented 3 years ago

I pushed a small bugfix that caused the menus to glitch sometimes. Builds are updated in the first (top) comment. If anyone is interested in a build for a different target - shout here, I'll upload it 😅

Hey! I just flashed this to my radio, seemed fine.. except, when I accidentally switched to sbus and back to crsf the menu was gone. I had to load another model, switch off the radio, switch on, reload elrs and it was back. Also, I doesn't look like wifi update is working on MacOs.. Chrome stalls at 17% and then wifi is lost... which brings me to another question, is there a way for me to see what version of expresslrs I'm running on my radio? ("version" in the menu would be nice..)

Thanks for the awesome work!

Wait for eLRS 1.1, it'll arrive soon and will work using the same code as existing CRSF support in deviation nightly builds. No need for the special build above (which is probably causing the issue you report with menus). No idea why WiFi update doesn't work- please report on eLRS GitHub.

Edit- the lua menu changes are now planned for 2.x cos they're incompatible with prior 1.x menu code.

tonvfx commented 3 years ago

I pushed a small bugfix that caused the menus to glitch sometimes. Builds are updated in the first (top) comment. If anyone is interested in a build for a different target - shout here, I'll upload it 😅

Hey! I just flashed this to my radio, seemed fine.. except, when I accidentally switched to sbus and back to crsf the menu was gone. I had to load another model, switch off the radio, switch on, reload elrs and it was back. Also, I doesn't look like wifi update is working on MacOs.. Chrome stalls at 17% and then wifi is lost... which brings me to another question, is there a way for me to see what version of expresslrs I'm running on my radio? ("version" in the menu would be nice..) Thanks for the awesome work!

Wait for eLRS 1.1, it'll arrive soon and will work using the same code as existing CRSF support in deviation nightly builds. No need for the special build above (which is probably causing the issue you report with menus). No idea why WiFi update doesn't work- please report on eLRS GitHub.

Wait? Haha.. with something this exciting? ;-) .. But that's really good to hear. I'll ask about the wifi update 'issue' on the elrs github/ discord... Like I said.. it's also possible it does work, but there's (in deviationtx at least atm) not an easy way to check version running on the tx afaik....

ghost commented 3 years ago

I pushed a small bugfix that caused the menus to glitch sometimes. Builds are updated in the first (top) comment. If anyone is interested in a build for a different target - shout here, I'll upload it 😅

Hey! I just flashed this to my radio, seemed fine.. except, when I accidentally switched to sbus and back to crsf the menu was gone. I had to load another model, switch off the radio, switch on, reload elrs and it was back. Also, I doesn't look like wifi update is working on MacOs.. Chrome stalls at 17% and then wifi is lost... which brings me to another question, is there a way for me to see what version of expresslrs I'm running on my radio? ("version" in the menu would be nice..) Thanks for the awesome work!

Wait for eLRS 1.1, it'll arrive soon and will work using the same code as existing CRSF support in deviation nightly builds. No need for the special build above (which is probably causing the issue you report with menus). No idea why WiFi update doesn't work- please report on eLRS GitHub.

Wait? Haha.. with something this exciting? ;-) .. But that's really good to hear. I'll ask about the wifi update 'issue' on the elrs github/ discord... Like I said.. it's also possible it does work, but there's (in deviationtx at least atm) not an easy way to check version running on the tx afaik....

Well.. i think if update dont work and it work on rx, they cant bind if both dont have same version..

Dropsleutel commented 3 years ago

Just to inform I had r9m running in t8sg v2 plus fine. (inc telemetry) (modified the tray) I flashed my r9m with ELRS firmware and it runs in OpenTx radio. Now I connected as such;

r9m_backpack_pins

I connected Rx1, to the CPPM pin. (and removed the transistor) I connected Tx Alternative location to Smartport pin.

I flashed https://github.com/DeviationTX/deviation/files/6503349/deviation-t8sg_v2_plus-v5.0.0-1dc62dc.zip

However in CRSF menu, I get an empty bar which I can move up and down. I don't see any Txt or data in the menus.

howels commented 3 years ago

Just to inform I had r9m running in t8sg v2 plus fine. (inc telemetry) (modified the tray) I flashed my r9m with ELRS firmware and it runs in OpenTx radio. Now I connected as such;

r9m_backpack_pins

I connected Rx1, to the CPPM pin. (and removed the transistor) I connected Tx Alternative location to Smartport pin.

I flashed https://github.com/DeviationTX/deviation/files/6503349/deviation-t8sg_v2_plus-v5.0.0-1dc62dc.zip

However in CRSF menu, I get an empty bar which I can move up and down. I don't see any Txt or data in the menus.

Did you change the UART inversion when building eLRS? Setting for T8SG is opposite of OpenTX.

Dropsleutel commented 3 years ago

I used R9M. Inversion is only availble for DIY ESP?

However I connected direct to tx rx pins as by picture above, so it should bypass the Frsky invertors on the pcb of the R9M ?

Teiho69 commented 2 years ago

Just flashed my T8SG v2 carbon with deviation-t8sg_v2-v5.0.0-575ef03 . My Happymodel ES900 tx works like a charm, so do my TBS Tracer tx. I'm glad that CSRF support for TBS Tx is not lost. Thank you really much.

kotyatokino commented 2 years ago

I'm using carbon T8SG with deviation-t8sg_v2-v5.0.0-575ef03.zip and ELRS1.0-1.1 works fine. But new 1.2 is not shown on CRSF menu. blank lines. Just only updated ELRS 1.2 without another changes from working 1.1 environment. Then I revert back to 1.1 and working fine now. Can we use ELRS 1.2 with this firmware?

howels commented 2 years ago

I'm using carbon T8SG with deviation-t8sg_v2-v5.0.0-575ef03.zip and ELRS1.0-1.1 works fine. But new 1.2 is not shown on CRSF menu. blank lines. Just only updated ELRS 1.2 without another changes from working 1.1 environment. Then I revert back to 1.1 and working fine now. Can we use ELRS 1.2 with this firmware?

What is your device name? Names > 12 characters don't render properly in DeviationTX.

phobos- commented 2 years ago

@kotyatokino I am currently adding support for v1.2 to spi rx, I will take a look at deviationtx side after bf side is done 😅 Please stick to v1.1 for the time being.

howels commented 2 years ago

@kotyatokino I am currently adding support for v1.2 to spi rx, I will take a look at deviationtx side after bf side is done sweat_smile Please stick to v1.1 for the time being.

If you know where the device name length limits are in DeviationTX that would be awesome to fix @phobos- , myself and @StonedDawg hunted for that and couldn't see where the 12 char limit is set.

kotyatokino commented 2 years ago

Thank you very much for your comments.

@howels

What is your device name? Names > 12 characters don't render properly in DeviationTX. I know this issue, and my dev name only 4 chars.

@phobos- Got it. Thank you for your effort.

phobos- commented 2 years ago

@kotyatokino I was able to reproduce your issue, looks like https://github.com/ExpressLRS/ExpressLRS/pull/897 breaks compatibility with deviationTX. I will look into it.

kotyatokino commented 2 years ago

@phobos- I just pulled your codes. My poor miss understanding was. crsf_uart.c > CRSF_Cmds(enum ProtoCmds cmd) > Model.proto_opts[PROTO_OPTS_RF_FREQ] was changed from TX module. because PROTO_OPTS_RF_FREQ is getting from tx module.

But the value didn't get from TX module by crashed. I clearly understand current situation. The code was merged to ELRS, so we need to wait the release 1.3 is better I think.

BTW, Do you have debug and build instruction page for deviation tx? DO you know the instruction availabe?

kotyatokino commented 2 years ago

Hmm... I didn't understand everything. ExpressLRS/ExpressLRS#897 's code is already merged with 1.2 release... We already compiled this fix, but it's not solved now.

phobos- commented 2 years ago

@kotyatokino this change is what BREAKS it, not fixes it. I removed this line from expresslrs code, compiled & flashed my ExpressLRS TX module and it started working again.

I changed: CRSF::duplex_set_TX(); -> //CRSF::duplex_set_TX();

Dropsleutel commented 2 years ago

Hi guys still to get back to use cases for the old red R9M's in T8SG still laying around covered in dust;

Anybody tried to hook up the external R9M UART Port into bay of T8SGV2 Plus ? Change ExpressLRS targets.h the RC pins to that port , so we should get rid of any nasty invertors ?

define GPIO_PIN_RCSIGNAL_RX PA10

define GPIO_PIN_RCSIGNAL_TX PA9


elif defined(TARGET_R9M_TX) || defined(TARGET_TX_ES915TX)

define GPIO_PIN_RFamp_APC1 PA6 //APC2 is connected through a I2C dac and is handled elsewhere

define GPIO_PIN_RFswitch_CONTROL PB3 //HIGH = RX, LOW = TX

define GPIO_PIN_NSS PB12

define GPIO_PIN_DIO0 PA15

define GPIO_PIN_MOSI PB15

define GPIO_PIN_MISO PB14

define GPIO_PIN_SCK PB13

define GPIO_PIN_RST PC14

define GPIO_PIN_RX_ENABLE GPIO_PIN_RFswitch_CONTROL

define GPIO_PIN_TX_ENABLE GPIO_PIN_RFamp_APC1

define GPIO_PIN_SDA PB7

define GPIO_PIN_SCL PB6

define GPIO_PIN_RCSIGNAL_RX PB11 // not yet confirmed

define GPIO_PIN_RCSIGNAL_TX PB10 // not yet confirmed

define GPIO_PIN_LED_RED PA11 // Red LED

define GPIO_PIN_LED_GREEN PA12 // Green LED

define GPIO_PIN_BUTTON PA8 // pullup e.g. LOW when pressed

define GPIO_PIN_BUZZER PB1

define GPIO_PIN_DIP1 PA12 // dip switch 1

define GPIO_PIN_DIP2 PA11 // dip switch 2

define GPIO_PIN_FAN_EN PB9 // Fan mod https://github.com/AlessandroAU/ExpressLRS/wiki/R9M-Fan-Mod-Cover

define GPIO_PIN_DEBUG_RX PA10 // confirmed

define GPIO_PIN_DEBUG_TX PA9 // confirmed

define GPIO_PIN_BUFFER_OE PA5 //CONFIRMED

define GPIO_PIN_BUFFER_OE_INVERTED 0

define GPIO_PIN_DIO1 PA1 //Not Needed, HEARTBEAT pin

define DAC_I2C_ADDRESS 0b0001100

define DAC_IN_USE 1


Shall I test it with latest code ? Deviation ExpressLRS code ?

kotyatokino commented 2 years ago

@kotyatokino this change is what BREAKS it, not fixes it. I removed this line from expresslrs code, compiled & flashed my ExpressLRS TX module and it started working again.

I changed: CRSF::duplex_set_TX(); -> //CRSF::duplex_set_TX();

Thank you for your explation. CRSF::duplex_set_TX() will break the way to CRSF_Cmds(). We need to find reason why . I will try it with my poor understanding.

kotyatokino commented 2 years ago

hmmm.. I just giving up debugging... When we see debug print , I need to buy phono plug UART converter cable..

howels commented 2 years ago

hmmm.. I just giving up debugging... When we see debug print , I need to buy phono plug UART converter cable..

Yes, it's the most awkward debug system. I thought the same thing.

Dropsleutel commented 2 years ago

I just gave it a re-try T8SG V2 Plus, with R9M ExpressLRS flashed, but the CRSF menu is not working for me.

dat-alex commented 2 years ago

Hi ! I 've just received my new HappyModel elrs 2.4 Tx module and trying it with T8SG plus .I get the classic problem with blankCRSF menus. Is there any Deviation fw build compatible with ELRS F4 2G4 AIO Flight Controller spi receiver already compiled for the plus with OLED (like Phobos no-OLED)?

Thank you for your time Alex

howels commented 2 years ago

Hi ! I 've just received my new HappyModel elrs 2.4 Tx module and trying it with T8SG plus .I get the classic problem with blankCRSF menus. Is there any Deviation fw build compatible with ELRS F4 2G4 AIO Flight Controller spi receiver already compiled for the plus with OLED (like Phobos no-OLED)?

Thank you for your time Alex

Try this https://github.com/DeviationTX/deviation/pull/1018#issue-1052703851

harlock00999 commented 2 years ago

Hi, First things first, thank you all for trying to keep Deviationtx alive and usable with ELRS! It is thanks to this post if I'm able to use a HGLRC TX 2.4Ghz on my beloved T8SG V2 PLUS! - THANK YOU ALL - (@phobos- you're the best)

Now, as many of you I was stuck with fw 1.1 since I read that 1.2 wasn't good yet.

But yesterday I flashed my tx with ELSR fw version 1.2.1 and everything seem to work just fine. The only bug I noticed is the power value that you can add on the main page of your model freeze sometimes and come back if you go in the model setup and re-int the CRFS module. Other values like LQ, RSSI work fine on both radio and Betaflight.

Thoughts? Questions? Comments? Do you want me to do some tests? Please keep in mind that I'm just a user...well, a smart user if you will ^_^

Thank you guys and happy flying

StonedDawg commented 2 years ago

@harlock00999 elrs stable V2 has been released, please use V2, and this PR from Phobos for your deviationtx Phobos deviationtx for elrs V2

harlock00999 commented 2 years ago

@harlock00999 elrs stable V2 has been released, please use V2, and this PR from Phobos for your deviationtx Phobos deviationtx for elrs V2

I'm going right now!!! Thank you!

phobos- commented 2 years ago

closing this, as expresslrs v2.0 is natively supported in deviationTX.

howels commented 2 years ago

closing this, as expresslrs v2.0 is natively supported in deviationTX.

There's still the 12 character limit, which many users struggle with. I'm using -DDEVICE_NAME to compile my eLRS TX with a shorter name, but would be great if the CRSF code could just concat fields to 12 chars instead of rendering a blank line.