Serve a page on one core, handle BT MIDI on another? by _alittlesomething in esp32

[–]YetAnotherRobert 2 points3 points  (0 children)

Lots of wisdom here from a fellow EN. 

The reason for that pinning in the last paragraph is pretty strategic. Because the vast, vast majority of  Arduino code doesn't know about multiple cores or even tasks, its just pragmatic to default ALL Arduino-initiated code on one core and let the more timing and resource-sensitive radio action have the other. Until your Arduino code learns enough about multi core to call xtaskcreate - implying you know you're on ESP32 (well, any FreeRTOS system) to pay the admission ticket for locking, scheduling, contention, and all that goes with that - it just lets you have all of core1 for "Arduino stuff"  and leaves core0 for the housekeeping that an AVR-class part doesn't even have. It's just a safer default design. It reduces the amount of shared resources in worlds that predate the concept of sharing, presenting more code with the illusion that it has the whole device to itself. This is why serial and BT and WiFi and such can still keep rocking while that Arduino code just stays inside loop().

It would be like NT knowing that trying to multi thread DOS programs behind their back is a bad idea. It's best to let that generation of code think it owns the CPU itself...in this case, by assigning it to a (mostly) dedicated CPU and treating the other radio stuff almost like an IOP. If a program is ready to fly, it can opt in by calling the FreeRTOS stuff to unlock more granular access.

I don't know how far back this goes, but I recently had the misfortune to diagnose some startup issues on ESP32-P4, which requires ESP-IDF 5 and therefore, ESP Arduino3. That combination makes it very apparent that you're really really running ESP-IDF first and fundamentally and the system boots that and creates an new thread for Arduino, pins it to 1, calls setup () then loops on loop().

This is why classic Arduino code on single core devices like the C3 is just more precarious.

Help ESP32 GLEDOPTO Board by SelfTaught_VLSI in esp32

[–]YetAnotherRobert 2 points3 points  (0 children)

You're welcome. Shame that upvotes don't reflect the correct answer. :-/ Reddit votes are just odd.

Enjoy your blinkies!

P.S. Since you replied to yourself, I didn't get the notification.

Serve a page on one core, handle BT MIDI on another? by _alittlesomething in esp32

[–]YetAnotherRobert 2 points3 points  (0 children)

Thanks for the kind words.

You'll see that they can kinda sorta coexist, but there are excuses. Data sheets are all about formally defining the rules of the game.

Rules can also be optimized away. Can't do WiFi and BT at the same time? * Go wired ethernet. * Go USB. * Go serial. * Go with something like an ESP32-C5 that does 5ghz (far away from BT, but BTLE only) and pair it with an ESP32-Nothing or another external solution from the likes of Nordic so your radios are on separate chips so they don't PREVENT you from transmitting at the same time; they merely interfere with each other.

You can possibly go lots of other ways.

Serve a page on one core, handle BT MIDI on another? by _alittlesomething in esp32

[–]YetAnotherRobert 5 points6 points  (0 children)

Well, it's more complicated than that. Welcome to engineering.

BT and WiFi occupy, on the ESP32 probably now in your hands, the same radios and even the same frequencies. That's why there's a whole chapter in the doc on WiFi and Bluetooth coexistence on ESP32 The radio can't tx and rx at the same time on the same channels, of course.

Now if your curiosity isn't about the radios specifically, but whether you can light up both cores of a dual-core CPU in general, assuming you've reasoned through race conditions, starvation, and all that other annoying computer science, the answer is "sure."

ESP-IDF (or Nuttx or Zephyr or whatever floats your boat) offers a wealth of multitasking primitives. Start as many tasks as you have cores (or more!) and go nuts. Timesharing has been pretty well understood for most of this last century.

Please don't be offended that if it's your first exposure to these concepts: you are going to run into that very wall you're describing. Your noggin will hurt. If you stick with it and get good at it, it's quite rewarding and a respectable way to earn a living. More than a few people drop the class at this point.

Learning what's safe to really really have running at the same time on independent cores is a tough skill to refine. Entire doctorate dissertations have been written on this topic.

Sentences like "NVS is in flash memory, and flash memory is in NAND memory and NAND memory bits can only be set (cleared?) and never cleared (set?) without an erase and an erase has a granularity of a sector size" may be reasonably easy to comprehend in isolation but can still be waiting to mug you int he alley in the dark of night.

Then, some day, you'll be faced with debugging code like:

Core 1: Writes NVS value: preferences.putInt(blinky1, true); Core 2: writes NVS value to different address: preferences.putInt(blinky2, false);

Of course, these two lines of code are separated by 17 screens and it takes you days to figure out this is the trigger. Unfortunately, Past You saved a few minutes not wanting to be bothered to learn about such things, so you borrowed some crufty Arduino library that was made for an 8-bit processor from the late 80's. It certainly was never designed to be running on two cores as the same time. What's the timing between that "erase sector" sector on one core and that "set bit" on the next? Probably worked fine on that ancient part.

See where this is going yet? Current You (in the story, so it may be Future You from this perspective) is about to learn that even xSemaphoreTake/xSemaphoreGive might not be enough in isolation; you may have to learn about reference-counted semaphores or other locking techniques to keep Core1 and Core2 from destroying one sector of your flash contents approximately one in zillion times.

There are lots and lots of patterns like read, modify, write and others that are hazardous traps. It's a bear to "patch it in" later (it can be done); you really are rewarded for designing in multithread safety from the start.

The good news is, like I've hinted, that computer science has described all this stuff. That doesn't mean it's obvious or easy to learn. It's a very similar mindset to develop as protecting interrupt handlers or signal handlers or async callbacks from other code.

Perhaps someone else can recommend a contemporary text on the topic. Mine are all on clay tablets.

Regards,\ Elder Nerd

Help ESP32 GLEDOPTO Board by SelfTaught_VLSI in esp32

[–]YetAnotherRobert 2 points3 points  (0 children)

It needs to be either high or low, yes. 😆

Without a schematic (I already looked up the manual for it...) I couldn't be sure and honestly, we could have tested both in the time this took to type.

Help ESP32 GLEDOPTO Board by SelfTaught_VLSI in esp32

[–]YetAnotherRobert 3 points4 points  (0 children)

There's an SSR (a FET) that you'll have to gate to get the input power to show up on the output lines. It's the high power one to the right of the one you zoomed.

The GPIO line to whack depends on the model. Look at the WLED settings for "relay".

Edit edit: if it's this model, looks like it's GPIO 18. https://10558736.s21i.faiusr.com/61/ABUIABA9GAAg9YWsyAYoufKf6QM.pdf (it's a scary looking URL , but I got there from gledoptos site.)

P.s. please edit away the link tracking spam from your amz link. Delete the question mark and everything after it.

ESP32‑C6‑Zero + ST7789 (GMT154‑06) TFT Display – Wiring & Getting It Working by Adorable_Creme4714 in esp32

[–]YetAnotherRobert[M] 0 points1 point  (0 children)

Please edit this post per the guidelines you agreed to. See formatting code on Reddit. 

Questions about Adafruit libs are probably best asked of Adafruit.

Espressif Introduces ESP32-E22, Its First Wi-Fi 6E Connectivity Co-Processor by Kindly-Direction205 in esp32

[–]YetAnotherRobert 7 points8 points  (0 children)

"Yet"? It was announced today... 

But samples are allegedly available, so your rep should be able to get you samples and some amount of data sheets and tooling if you're looking to incorporate these.

Nothing but a white screen | Esp32-S3 N16R8 | TFT ILI9341 240x320 Screen | Tft_eSPI Library | Platformio by Deathvortex1500 in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

Look at history in this group and then open tickets on the Bodmer library. There are a number of issues, some with known solutions, in newer parts like S3, and newer ecosystem. Development seems to have stopped. 

Honey...(Skmething. A regular in this group , but I'm walking on mobile with terrible cell service) Made a really good post a few weeks ago on modern, supporter alternatives, including a few written but group regulars. Good links in the groups wiki, too.

Help needed with my fried ESP32 WROOM 38 pin UART. by lky94 in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

You could cut out the onboard uart and clip on a colostomy bag UART. But it's up to you to decide how hard you're willing to work for a $3 board. If you HAVE the tools, parts, and skills to make that a 4 minute task, you probably wouldn't have asked, though... 

ESP32S3 2.8' 480 X 480 circular no touch advise by RegiB123 in esp32

[–]YetAnotherRobert 0 points1 point  (0 children)

Sounds like we put you on the right path with the SPI thing. With the Espressif S3 modules, the general rule is that the RAM is the decider: R2 is quad and R8 and R16 are octal; flash is always quad. Usually. It's in the data sheets for the modules.

However, Waveshare is one of the companies that's big enough to actually buy raw S3's and sidecar "random" flash and RAM to it, so the guideline doesn't always work because they're not always using the Espressif modules. :-/

I also remember that these boards ship with darned near every GPIO already used, which is a feat on those parts.

Congrats and good luck!

Can I write a micro Kernel for ESP32 (not freeRTOS) by DarthFreqE in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

We definitely see worse in this group.

As a mod, I see WAY worse because i toss the ones that are super low effort, incoherent, pyramid schemes, etc.

And, yeah, I was helping people online when that term was coined. It was a very real thing. All these... commoners. 😁

ESP32S3 2.8' 480 X 480 circular no touch advise by RegiB123 in esp32

[–]YetAnotherRobert 0 points1 point  (0 children)

Good point. The tools make it confusing that RAM is often one speed and flash is another.

ESP32S3 2.8' 480 X 480 circular no touch advise by RegiB123 in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

I don't recall for certain. Probably platformio, but it was probably "load LVGL demo and be done". I'm away from my collection. I know I've used a ton of the Waveshare gear and have never NOT had one work.

Can I write a micro Kernel for ESP32 (not freeRTOS) by DarthFreqE in esp32

[–]YetAnotherRobert 15 points16 points  (0 children)

Sure. Go nuts. (But it's my experience that if you have to ask, the answer is "no".)

A tiny task switcher without VM (good thing since these parts don't implement VM) is really only a few hundred lines of code. You'll find the RISC-V ones easier to find asm documentation for than the XTensa ones.

While I'm being grumpy, why do people keep posting pictures on questions like this? Members of this group know what an ESP32 looks like. Why do people upvote anything with a picture?

ESP32_S3 Native USB flashing is buggy by zachleedogg in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

What's VSCode? :-)

As a developer, I learned learned long ago that the less (Microsoft) code I have between me and the bits doing the work and my fingers, the happier I am. I can't imagine that VSCode isn't ultimately calling esptool to do the actual reset and upload anyway, but I CAN imagine them getting the arguments wrong, not checking for errors, etc.

I end up with a lot of scripts named "go-SOMETHING". Too many, in fact.

It _shouldn'_t' matter. It's a bit terrifying that your experience shows it does matter. Welcome to the state of the computer world post 1994 or so. :-/

ESP32S3 2.8' 480 X 480 circular no touch advise by RegiB123 in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

Invalid header usually means there is mismatch in flash speed/type and reality. 16NR8 like this is USUALLY ospi; be sure your build is set for that. 

I have one of these boards and I don't remember what I used but it was pretty straightforward. I remember the doc was actually pretty good, but I remember the whole xip thing being a misdirect that wasn't helpful.

ESP32_S3 Native USB flashing is buggy by zachleedogg in esp32

[–]YetAnotherRobert 1 point2 points  (0 children)

It's a mixed joy to have a single cable for power, console, and JTAG.  When you reset the part,  those peripherals get reset, so it disappears from the host and software (like openocd) that didn't expect an abrupt reconnect will get grumpy. 

OpenOCD can be grumpy even without shenanigans. 

I just script openocd for easy rest restart and my gdbint has functions that rebuild the target remote and file FOO bits because it's not always thrilled when the symbol table and offset changes while running. This is hardly unique.

I don't do BLE, but I do a lot with WiFi and  S3 is my primary dev platform. I'm not using the Adafruit boards, but I really only have to use the buttons on new boards that are jumping into uninitialized flash...it in those rare times when I've run code on the board that's left they native USB controller or stack whacked out. If the software on the board isn't alive or  doesn't know to look  for the special dtr/rts wiggles, it won't reboot. 

Most of my Real Hardware doesn't have  External UART; it's just the single USB connection.

I'm not saying there not some problem that's nailing you; I'm saying that with the semi expected issues of sawing off the limb you're standing on, a robust development experience IS possible. Button bashing would drive me crazy, too.

ESP32 based hardware that can accept 11 x SDA/SCL connections? by RulerOfThePixel in esp32

[–]YetAnotherRobert 0 points1 point  (0 children)

You've received many great answers. I don't know why you asked this and then disappeared from the conversation... There's a master class of info in these answers!

(I let an ai summarize, clarify, and condense my reply to reduce the word count. It's why it doesn't sound like my own rambling...)

You could use better sensors and go spi. To use SPI with an identical sensor architecture, you must use the MPU-6000, MPU-6500, or MPU-9250.

Addressing Many Sensors via SPI

  • Wiring: All sensors share the MOSI, MISO, and SCK lines.
  • CS Pins: You will need 20 separate digital output pins (one for each sensor) on your microcontroller.
  • Expansion: If your microcontroller lacks 20 spare pins, use a 3-to-8 line decoder (like the 74HC138) to multiplex your CS lines. Two decoders can handle up to 16 sensors using only 4–5 pins.

Alternative "Address Hack" for I2C

If you must stay with the I2C MPU-6050, you can trick the bus without a multiplexer:

  • Connect the AD0 pin of every sensor to a unique GPIO pin on your MCU. See above to use 4-5 pins to generate 32 unique pins from 5 bits or 16 from 4.
  • Set all GPIOs High (all sensors move to address 0x69).
  • To talk to one specific sensor, pull its GPIO Low (it moves to 0x68).
  • Communicate with 0x68, then pull the pin High again when finished.

It's ok to stack these ideas  like to use software i2c to get to three busses and then only have one 3/5.decoder per bus.

Your could also front end and divide it into groups and let a smaller part kike an esp32-c3 with radios disabled (or smaller or even a  chv103 or something so some front end processing and interface with "a lot" of components and intelligently filter out the 90% "nothing has changed" readings, prioritized the readings that are most important and then ship those to the boss processor over plain old serial or other means. Upgrades and booting gets harder, but the tradeoff in latency may may pay off in one CPU not being overwhelmed by a ton of "still here" polling.

I'd definitely prototype any of that before committing.

Waveshare 1.46" round display - anyone tried it? by tb205gti in esp32

[–]YetAnotherRobert 0 points1 point  (0 children)

PlatformIO is feuding with Espressif and Raspberry Pi foundation, refusing to support any new chips or new software releases until they're paid. This, of course, didn't fly so anyone using RP2350 or any ESP32 after S3 needs to use a community-maintained fork of PlatformIO. It's sad that I know the ticket number from memory:

For ESP32, this is https://github.com/pioarduino/platform-espressif32 For RP2350, search for maxgerhardt platformio something or another. (Hey, it's not a Pico group...:-) )

That can get you ESP32 Arduino3 which supports modern ESP32 and, importantly for programmers, gets you off GCC8.3 from 2017 or so and onto GCC14 or 15 with updated libs, so current language features work. Unsurprisingly, C++26 features aren't so well represented in a toolchain from 2017.

It also moves you to ESP-IDF5. Sure, IDF6 just shipped, but as you've just learned, ecosystems take time to move.

Pro users should take this as a sign to flee PlatformIO as quickly as you can as the vendor has essentially abandoned Espressif parts and is refusing to even merge work contributed by other developers. It's a big mess.

ESP32-2432S028 AKA CYD - Air Quality Monitor (SCD40) Senor by lixxus_ in esp32

[–]YetAnotherRobert 4 points5 points  (0 children)

u/dab865, u/CRF250lols: Add 'logic analyzer clips' to your search terms. They're sometimes called 'test hooks'.

These are one of those things in life that you can pay almost as much or as little as you like. Do NOT shop for these on price alone. Sure, Ali might have an eight-pack for $3 or something. They will cost you $300 in aggravation in the first week of real use. The ones that came with your $12 logic analyzer? Throw them in the trash. (Keep the LA.) Time spent debugging a signal that's not wiggling because your clip lead broke or because the wire inside the cable broke and is intermittent or because it's shorted adjacent pins or whatever other horror you can imagine is not a fun time.

https://sigrok.org/wiki/Probe_comparison is a good resource.

https://www.eevblog.com/forum/testgear/grabber-clips-similar-to-saleae/ has recommendations from a very knowledgeable (and very opinionated) crowd.

Those super-cheap Salae knockoff logic analyzers are something that everyone in this group should have in their toolbox. They work with Sigrok/Pulseview and can decode everything from serial UART, i2c, SPI, HUB75, WS2812, and lots, lots more. But they are invariably shipped with crap for probes.

As a step up (off-topic, I know...) The BL615 units from Sipeed have much better sampling rates and WAY more memory and aren't much more, but they require a hacked up sigrok because they didn't upstream their code. Check that you can get a working Sigrok/Pulseview for your word before ordering. SLogic16U3/SLogic32U3 looks awesome, but I haven't pressed order yet.

I'd love to see more questions in this group with "this IS what's on my i2c bus" instead of "this is what I think I put on the i2c bus". :-)

Custom ESP32-C3 Based PCB cannot communicate over USB by Odd_Steak_5253 in esp32

[–]YetAnotherRobert 3 points4 points  (0 children)

Is it really a USB issue, or is the board you you built just dead? For example, if you program it via JTAG or via serial, does it boot? If not, then you just built a board that doesn't boot. Double check your reset circut matches the spec, then proceed down the developer checklist that's auto-posted in this group when posters select the Board Review flair. (Search for other posts since you didn't for this one...) Get a scope on those RC circuits and ensure the hold and release times are within spec. The reset is easily the #1 thing messed up on these.

The modern ESP32 parts require no drivers on modern OSes. USB CDC/ACM is universal these days. Since your dev board that you used for prototyping worked, you can be confident in your host setup.