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

support ESP32/ESP32-S3/ESP32-C3 #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jafrado
Copy link

@jafrado jafrado commented Jan 11, 2023

Support ESP32 modules. See README.md for more details. Probably the next step is to factor out the ifdef'd code and provide a hardware layer per chip/module.

@jafrado
Copy link
Author

jafrado commented Jan 11, 2023

See also the mavesp8666 version.

@jafrado
Copy link
Author

jafrado commented Jan 11, 2023

@DavideLentini - please send me email when you'd like to review the failure.
@markingle - please test this one and let me know what hardware you are using.

@jafrado
Copy link
Author

jafrado commented Jan 11, 2023

I have a couple different custom boards. It seems the one everyone thinks I should build is the ESP32-S3. Thoughts?

@markingle
Copy link

@jafrado i am using a ESP32 DevKitC w/ WROOM-32E. I'm running a custom version of Arudupilot from Skybrush based on 4.3....I'm not sure how this relates to your PX4 comment. I'm rather new to the AP echo system

@jafrado
Copy link
Author

jafrado commented Jan 12, 2023 via email

@markingle
Copy link

Exactly!!! The WROOM is a great SoC to prototype with and PCBWAY always has them in stock. I already have several DipTrace designs with a 5v and 3.3v power rails as well as the LDO with a bat charging circuit to keep the ESP32 running w/o using the drone battery. Once I get to a point being able to compile your code and confirm passing MAVLink 2.0 to the drone I will be working to trap MAVLink LED commands. This will also require an I2C interface with the 3DR LEDs.....I think. The schematics are old and its hard to tell where the I2C travels on the PCB....Thank you so much for making your code available!

@markingle
Copy link

Something similar to this design except an LDO w/ battery charging circuit...image

@jafrado
Copy link
Author

jafrado commented Jan 12, 2023

@markingle - thanks, yes, that would be the idea. I already have an ESP32-WROOM design that is solid. Below is a picture of my router board which supports the original ESP8266, the ESP32-WROOM, XBee Pro WAN module, and LORA-E5 module.
A-Side is a separate CPU with 5 COM ports.

image

B-Side shows ESP32 and E5 module tucked away.
image

Also attached shameless shot from vehicle at 125K AGL (almost half-way to space). Tracked vehicle throughout flight and routed over WiFi with this code.
image

Probably next version I will compile my router code on latest Apache NuttX 12 which supports ESP32-S3/C3 already;
so this may be my last update of this source base!

Your idea on the LED is a good one, the original 3DR code uses a chip that the PX4 / Ardupilot firmware knows about already so you would just need the 4-Pin I2C and it will just work, I will have to lookup the circuitry for that, let me know if you are interested.

@markingle
Copy link

No that's pretty much outer space! Very impressive! Thanks for sharing. If you have the schematics (or any info) that would be a great jump starter.

@markingle
Copy link

@jafrado What pins are used for tx/rx to the Cube in your code? I am using 16/17...

@jafrado
Copy link
Author

jafrado commented Jan 13, 2023

@markingle - thanks, lots of fun! Probably will have some better shots in the months ahead.

Yessiree sir, yessiree - below are the schematics, yes, IO16/IO17 are the pins (package pins 27/28). See below.
If you're interested, I can do a simple layout with this and do a fast turn. Send me your wishlist. I know you wanted NeoPixel, if you look at the mavesp8266 PR's here is the NeoPixel mod it's almost zero engineering (IO12 since it was tested). I will add that for visual indications and any other sensors you want so long as we keep it tiny/small. On mechanical dims, I was thinking 25mmx50mm (roughly 1x2"). 4 M3 holes and it could fit on any drone. uFL to SMA and external Antenna mount so you can get some range. Next revision we could put an external PA (ePA) and get some serious range... but that would be v2..

image

@jafrado
Copy link
Author

jafrado commented Jan 13, 2023

By the way, I'm driving that with an LM1086 (5A) and 1mF cap. For this design, I would use LM317 and a 10uF/20uF SMD with an option for electrolytic (PTH) - think of cheap, cheap new old stock 🥇
Another discussion point, use the ESP-PROG header and connector FTSH-105-01-S-DV-*, and make it a snap-off on the side of the board when factory programmed.
Ideally I would use a TAG-Connect like TC2050-IDC-NL on the debug side of the board but that would not necessarily be standard, or at least you would need to get a TC2050 cable for your ESP-PROG. Thinking about it, I would probably need both.

@markingle
Copy link

I doubt I will manufacture what I'm building. I'm really not that experienced (4 years) with PCB design and I'm self-taught. Got the burned up boards to prove it!!! The work is almost therapeutic though and I do enjoy learning new skills that allow me to do creative problem solving. But to your point I did use the LM317 on my last project!

Do I need an ESP programmer? I'm having trouble getting the parameters to save consistently and when debug is enabled the esp core dumps repeatedly...I have separate Wi-Fi network called Skybrush and a static ip assigned but the esp becomes inaccessible after reboot...weird!!!

@markingle
Copy link

Not making much progress...It appears that I really should be using a debugger to work with the code. I had to add Serial.println statements to understand what is going on with the AP/STA setup. I finally got the ESP32 connected to my wifi network. After checking the Rx/Tx (16/17) pins with my analyzer I dont see any data coming across. The 3DR Solo is turned on. The baudrate is 115200 for Telem1 - confirmed with Mission Planner. Serial Protocol is MAVLink 2.0. I was expecting the ESP32 to at least send a heartbeat.

The screenshot shows the output from the serial.println statements. I am currently tying to track down the "RX Buffer..." error. I dont think I caused it but I am not sure at this point....Let me know if you have any thoughts....

...kind of frustrating but still encouraged with my progress...it will be worth it in the end.

Screen Shot 2023-01-14 at 8 35 39 PM

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@markingle
Copy link

I'm using platformio. The command is ... platformio run -e espwroom32 -t upload. I'm using an ESP32 Dev board. While troubleshooting I have changed the telem baudrate to 115200 in all the header files...I'll change it back if needed though.

I just found where Serial.swap is called before Serial.setRxBufferSize when the code is ran on a 8266. The setRxBufferSize call probably assumes the swap has been ran successfully. And I am not sure if the ESP32 supports serial.swap....time for some reading I guess.

@markingle
Copy link

markingle commented Jan 15, 2023

Finally got connected to the telemetry from the CubeSolo(3DR Solo).....the ESP32 does not support Serial.swap so I had to add HardwareSerial.h to mavesp8266_vehicle.cpp and create ESP32Serial1 to enable pins 16/17.

image

I am not getting a heartbeat so I need to track that down.....Also MAVProxy is not picking up the UDP connection so I got track that down too...

image

@markingle
Copy link

Here is the code that I added...

Screen Shot 2023-01-14 at 11 44 25 PM

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@markingle
Copy link

The dev board has a usb connection to UART0 Serial....image

The serial architecture on the ESP32 is different than the 8266...at least that's what I have concluded

@markingle
Copy link

Here's a better pictureimage

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@markingle
Copy link

markingle commented Jan 15, 2023

Notebook version....the IMX board has been removed

image

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@markingle
Copy link

Yes I am able to program the ESP32 I just can't see the logging output when the program runs....but it all good now that I understand what is going on with the code

The dev board is a WROOM module. See attached picture...image

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@jafrado
Copy link
Author

jafrado commented Jan 15, 2023 via email

@markingle
Copy link

Yes I agree. I just don't have one. I'm definitely going get one ordered as soon as I can.

@markingle
Copy link

@jafrado Thank you for making this PR available! I have the code working to support my needs for doing drone shows with the 3DR Solo! Once I get the drone show tested with several drones I will work to build in LED control through MAVLink commands trapped out by the code....fingers crossed!!!

@jafrado
Copy link
Author

jafrado commented Jan 19, 2023

Thanks @markingle , have fun and keep me posted on your progress and findings!
Thank you

@hi6otb
Copy link

hi6otb commented Mar 15, 2024

I've successfully used the ESP8266 with no issues, but after building and flashing the firmware to the ESP32, the WiFi does not appear.
Has anyone faced a similar issue, or are there any additional steps needed to enable WiFi visibility on the ESP32?

@jafrado
Copy link
Author

jafrado commented Mar 15, 2024

@hi6otb - you should find an AP named Pixracer and make sure you are using a 2.4Ghz channel on your host machine.
If you find that you cannot locate the AP then disconnect your WiFi from whatever AP you are currently connected to, and
then wait for the host to rescan and detect the AP. AP is going to beacon about every 100ms, so if you are not seeing Beacons
that would be due to an antenna issue. To isolate that and bisect on debug, move the host machine very close to the antenna.
You can also force max power in the firmware (search for power), and if you have a uFL module, try to use a 2.5dB whip or ducktail antenna versus an Omni (0dB) dipole.

@hi6otb
Copy link

hi6otb commented Mar 15, 2024

@jafrado - When I build for the ESP01 and flash it onto an ESP8266 board, an AP named 'Ardupilot' appears and functions correctly. However, after building for the ESP-WROOM-32 and flashing it onto an ESP32 board, no AP appears.
Is the code altered to show 'Pixracer' as the default AP name for ESP32? If so, I might not have the correct version of the code.

Could you provide the firmware.bin for ESP32, if possible?

@jafrado
Copy link
Author

jafrado commented Mar 15, 2024

@hi6otb - sorry, I was wrong - the SSID is Ardupilot, I didn't change this in the tree because I wanted to merge this PR.
Anyhow, some things to review:

921600 Default UART Speed
https://github.com/RealFlightSystems/mavesp8266/blob/master/src/mavesp8266.h#L76

Ardupilot as default SSID
https://github.com/RealFlightSystems/mavesp8266/blob/master/src/mavesp8266_parameters.cpp#L44

Default WiFi channel 11
https://github.com/RealFlightSystems/mavesp8266/blob/master/src/mavesp8266_parameters.h#L51

Make sure you are building for the correct board, for example esp32wroom

https://github.com/RealFlightSystems/mavesp8266/blob/master/platformio.ini#L49

Follow the README here

https://github.com/RealFlightSystems/mavesp8266/blob/master/README.md

For debug, please try changing the SSID and make sure the platform you are using (-e setting) is correct for your board.
Not all ESP32 have the same memory attached, so you will need to confirm this to program your board correctly otherwise
it will not boot. You can also try changing the Channel (try 1, 6, 11 default).

I can send you a test firmware this weekend, but it sounds like the issue you are facing (if programming your board does not bringup the AP - e.g. you don't see Beacons) then the memory configuration or board configuration is wrong.

Please check the above and let me know what you find.

@jafrado
Copy link
Author

jafrado commented Mar 15, 2024 via email

@jafrado
Copy link
Author

jafrado commented Mar 15, 2024 via email

@hi6otb
Copy link

hi6otb commented Mar 15, 2024

@jafrado
I'm targeting the M5Stamp-Pico board and have added the following to my platformio.ini:

plaintext
Copy code
; M5Stamp-Pico
[env:m5stamp-pico]
platform = espressif32
framework = arduino
board = m5stamp-pico
build_flags = -D ARDUINO_ESP32_DEV
debug_tool = esp-prog
upload_protocol=esp-prog
The build completes without issues. I use the following command to write the firmware.bin generated in pio/build/m5stamp-pico:

plaintext
Copy code
esptool.py --port /dev/tty.usbserial-0001 write_flash --flash_mode dio --flash_size detect 0x0 ~/Downloads/firmware.bin
The flashing is successful.

Am I making a mistake somewhere? I've tried various boards (esp32-wroom-32, xiao ESP32S3, etc.), but the WiFi AP does not appear. It works fine with ESP8266 (ESP-WROOM-02).

@jafrado
Copy link
Author

jafrado commented Mar 15, 2024

@hi6otb - thanks for that. I looked at the board here: https://docs.m5stack.com/en/core/stamp_pico?id=schematic

Two things come to mind:

  1. Is the esptool reporting a 4MB part? As you can see on that bottom page, it is a 4MB ESP32WROOM module.
  2. You have to first program the ESP32 downloader such that ESP tool will recognize the part. Do that first before
    trying to program it (you need the USB/Serial adapter or an FTDI USB serial cable)

Now lets get a look at your esptool output log. See also here for debugging FLASH woes:

https://community.platformio.org/t/esp32-flash-memory-size/26669/5

@hi6otb
Copy link

hi6otb commented Mar 16, 2024

@jafrado
I flashed it by esptool with FTDI USB tool that reported 4MB flash.
This is full log.

me@myPC ~ % esptool.py --port /dev/tty.usbserial-53240003841 flash_id
esptool.py v4.7.0
Serial port /dev/tty.usbserial-53240003841
Connecting..........
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 4c:75:25:c4:65:c4
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

@jafrado
Copy link
Author

jafrado commented Mar 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants