[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1757519534975293.jpg (37 KB, 250x397)
37 KB JPG
I just bought pic related to learn some embedded programming. Does anyone know a good ESP32 tutorial, (short) book or whatever? On YouTube practically everything I found is shit and most tutorials say "use muh Arduino" or "use muh bloated idf bro, don't understand things bro". Is there something that starts from scratch so that I can really learn all the low level concepts? I don't want to use abstractions like arduino's shit.

I found this guy's channel and his videos seem to be in-depth enough, the problem is that I want to do this in c if possible (I don't know rust and I'm not interested in learning it right now)
https://www.youtube.com/watch?v=l75TfMOPG1g
>>
>>109078983
Choose project with it and just do it.
>>
>>109079136
That's not the way I learn. I need to know the basics of the topic well before starting to do real stuff. Otherwise I will have massive gaps in my knowledge and I'll feel like I didn't understand anything
>>
>>109079161
Read nand2tetris first, then
>>
>>109079314
Come on man
>>
>>109079322
What are you expecting? You want low-level, but why and how low-level? Do you write your other programs bypassing kernel or HAL?
You'll always be building on abstractions if you make anything meaningful.
>>
>>109078983
>>109079161
The first step of learning embedded programming is learning how to find information on your own.
>Is there something that starts from scratch so that I can really learn all the low level concepts? I don't want to use abstractions like arduino's shit.
kek, go read the reference manual then lmao

https://documentation.espressif.com/esp32_technical_reference_manual_en.pdf
>>
>>109079347
>>109079353
Probably I have the communication skills of a nigger (ESL). What I meant is that, say, you want to learn c. You don't just go and say "just build a raytracer lmao, you'll figure it out" when you don't even know how to write an if statement. I would start with something like K&R just to understand the structure of the language and then go from there.

At the same time, I would avoid tutorials that just tell you to click on a few boxes in order to compile a program and skip all there is to understand. This is because these tutorials give you no understanding on the compilation process and what's going on, even at a high level.

Probably I need some abstraction at this stage, but I feel like Arduino is just too high level slop and it's at the wrong level.
I was probably wrong about idf though.
>>
>>109079404
As far as the code is concerned, it's always just reading and writing the pins plus whatever normal code you need in there. Often some code for talking with the BLE/WiFi, but you would usually want to do that through a library. For me at least, no interest in reinventing the wheel and writing a half-baked BLE library.
Maybe some methods will abstract away the pin reading and writing, but in those methods you just write the pin function once, then call it as if it was premade anyway. It's not much of a learning experience unless you are interested in developing the ESP itself rather than developing using the ESP.
Same with compilers, for almost all programmers they are just a means to an end. Unless you are actually developing a compiler it's not really that important how it works. There's a few little tidbits that might help you optimise your code, but that's few and far between.
When that other anon recommended you do a project, it doesn't necessarily mean something very complicated. Deeper understanding comes from use and exploring and understanding edge cases. There might be some other programming fundamental you don't understand, but you won't necessarily come to understand it by just going lower level.
Start by looking into idf. Most of these approaches are just C at the heart of it, so you can just stick to C functions plus their pin functions.
>>
I wish this was more popular on this board. the hold up for me comes when I want to add like 10 things to the board, a display, hardware clock with its own coin battery, regular battery with uninterruptible power supply circuit, and have it all work together the right way. it kind of seems like for whatever project you have in mind, there is a chinese board you can just buy (singularly or at individual scale) as a product with the microcontroller, half of the stuff you want, but works as a prototype and most of the code you write for it could also fit your goal idea.
really turning your idea into reality must have more to do with designing a pcb. then you can order infinite copies. I wish people talked about that here so I could passively absorb the knowledge.
>>
>>109080070
check out >>>/diy/
>>
>>109078983
ask AI
>>
>>109078983
>I don't know rust and I'm not interested in learning it right now
It's not that hard if you already really know C.
Wherever I see ESP32 mentioned, it's usually someone who is already on the embassy hype train. So you might as well get on it early on.
>>
>>109078983
bro it is late 2026 go ask AI for absolute basics
they can make up custom tutorials on the spot that fits your level
>>
>>109082207
I think this is a bad idea. After reading through an ai tutorial, you are left with no understanding whatsoever, especially if you know little about the topic in question.
It gives too many details when I don't need them and gives to few when I need them. You could keep prompting it for clarifications, but this only works if you already know somewhat the topic at hand.

It would be like a complete beginner who doesn't know how to code trying to learn to program in c just by browsing through random questions on stack overflow: too little structure and the learner doesn't even know what to look for.
>>
>>109079717
Ok thank you anon, I will start looking into idf and go from there.

Also, would you say that books like "Programming The ESP32 In C Using The Espressif IDF" are worth reading (442 pages) or should I just read the official documentation / tutorials?

Also, I know basically nothing about freertos, maybe this is relevant.
>>
>>109078983
You need to learn C programming and basic electronics first.
>>
File: 1767444273020516.png (157 KB, 1259x816)
157 KB PNG
>>109078983
Get something simpler for learning. esp32 are great, but for low level stuff (manipulating registers without using the SDK, linkers, etc), it's way too complex. Get an AVR (arduino uno) and play around with atmel studio instead of arduino ide. Atmel studio generates a HPL/HAL for you and you can examine the generated code and see exactly how it manipulates registers to for example read UART, use systick, use other peripherals, etc.

picrel is example generated hpl code for saml21g18b.
>>
>>109082437
I already know those, especially programming in c (though, it depends how advanced my electronics knowledge should be)
>>
>>109082401
isnt all good tutorial like that?
build something fun to play around first and then tweak stuff around, find out why shit breaks and start to actually learn
>>
>>109078983
SAAR PLEASE SOMEBODY HELP ME SAAR!!!!!! I NEED HELP AND ADVICE ON A TOPIC WHICH HAS INFINITE RESOURCES AND BEGINNER TUTORIALS AVAILABLE PLEASE SOMEBODY HELP ME AND TELL ME IT'S ALL GOING TO BE OKAY PLEASE SAAAAAARRRRRRRRRRRRRRRRRR
>>
>>109082541
if you want to learn "embedded programming" you should probably know how the basic digital/analog interfaces work (spi, i2c, what is PWM, open-drain/open-collector) on the electrical level. these are the most common ones you have to "debug", and these connect 95% of all digital sensors
since you say you know C, there are really only specialized "programming" topics that you can learn as needed. for espressif chips, they all use freeRTOS, so it'll be good to know how that works. but you can learn that as needed, it's not that complicated either.
>>109079353
>The first step of learning embedded programming is learning how to find information on your own.
this guy knows
>>
you basically bought a super computer and are trying to learn 8008 concepts on it. its fine, but you're inviting abstracted magic. these build kits aren't for that, they are so redditors and children can make clocks.
>>
>>109082514
>but for low level stuff (manipulating registers without using the SDK, linkers, etc), it's way too complex.
nobody uses embedded chips without their SDK
esp32 SDK is an open source collection of CMakeFiles and python. the TRM tells you exactly which registers you would need to manipulate to access each and every single peripheral. same as any other SDK i've had to use. nobody reads those pages in the TRM. because nobody does that.
>linkers
the standard way to build the projects literally prints the linker invocation as it's last line before "build successful". im not a cmake expert but I wager it's rather trivial to modify the linker call.
>picrel is example generated hpl code for saml21g18b.
completely pointless to look at and study, the TRM explains this kind of stuff without you having to guess whats inside CTRLA or CTRLB.
>>
>>109083165
OP says he want to learn low level concepts from scratch. If he wants to learn a SDK and wire some shit, sure, use whatever. Obviously no one rawdogs mcu code unironically, people don't even write code themselves nowdays
>>
Read fhe esp32 docs lmao


No really just use the arduino lib and read arduino tutorials, at some point you may need esp32 specific shit like the two cores but that still also works with thr arduino frameworkl

t. uses esp32 at work
>>
File: IMG_1108.jpg (187 KB, 828x1564)
187 KB JPG
Posted in the wrong thread>>109083356
Pic unrel because iriginal 4chan wont let me report. Fuck this place


repost:

#include <WiFi.h>
WiFi.begin("SSID", "password");
while (WiFi.status() != WL_CONNECTED) delay(500);


Then try this
https://github.com/CamM2325/microlink
>>
>>109079161
Asking this on /g/? Really?
>>
>>109083826
What?
>>
>>109083133
nobody learns shit from the ground up
good learning material bait them into having fun playing so they stick around and explore and eventually start learning on their own
>>
>>109082426
Depends on what your goals are, and how well you learn from books versus other means.
Considering you said at the start your goal is to learn some embedded programming, I would start with simple electronic components on the GPIO pins like LEDs, switches, and pots. At this point, the main thing you can learn is "this is programming, but I can control components that interact with the physical world outside my computer" and then expand your knowledge of what those components are and what you can use them for.
Later there's stuff like how to make your programs leaner, or how to program boards without the USB port on them, and other little specifics, but honestly unless you take this up as a job you plausibly won't ever need any of that.
To me, 442 pages if not worth what the author claims you will get out of that, and often those books pad out or assume you are coming at things as a complete beginner, so the documentation will have less fluff and less handholding. Maybe you want or need the fluff and handholding though. That depends on your experience with programming and parsing documentation.
Since you haven't even written an ESP program yet, or blinked an LED, FreeRTOS is really not necessary right now. It's more efficient to wait until a project you are undertaking needs something before you spend time learning it. For example, a project I am working on needs Abstract Syntax Trees, but if I had learnt ASTs before needing them I would have had no way of knowing that is what I needed, and would have learnt a bunch of other stuff that I never had a use for too. Sounds fine in principle but in practice it holds you back from spending time on the projects you actually care about.
>>
>>109078983
Check out random nerd tutorials. Decent projects, and you can buy his ebooks pretty cheap. Does both C and micropython.
If you want home automation, take a look at esphome.
>>
>>109078983
>I don't want to use abstractions like arduino's shit.
go to espressif's websites and download the datasheets and write your own firmware then retard

but we both know youre larping
>>
>>109078983
what do you want to do? is this the risc-v or xtensa chip?
anyway, you can start by identifying how the chip knows where to start from.. fixed location, or some boot identifier word and then write the startup assembly code

below is startup code i wrote for the cortex m4 on my stm32f411
.set VTOR_REG, 0xE000ED08

.text
.thumb
.globl _start
.globl reset_handler

_start:
reset_handler:
cpsid i # Disable interrupts out of reset, RTOS enables them later

# Clear GPRs
mov r0, #0
mov r1, #0
mov r2, #0
mov r3, #0
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0

# Set VTOR to default vector table location
SetVTOR:
ldr r0, =VTOR_REG
ldr r1, =__VECTOR_START
str r1, [r0]

# Initialize SRAM to zero
InitSRAM:
ldr r2, =0x20000000
ldr r3, =0x20020000

movs r0, #0
movs r1, #0
SRAMLoop:
stm r2!, {r0, r1}
cmp r2, r3
blt SRAMLoop

# Set the stack pointer only after SRAM is zeroed
SetStack:
ldr r0, =__stack_end__
msr msp, r0

__MAIN:
bl main


on ARM the first word in the exception vector is the initial stack pointer location. i don't use this mechanism since it lends itself to issues if you have uninitialized ECC on the TCM or RAM where the stack is located.
i've stopped doing a lot of initialization in assembly, just keeping to the bare minimum to minimize the amount of manually written assembly code.
so the first thing that the main entry does is to zero-init the BSS and copy ROM data to RAM, followed by explicit calls to preinit_array and init_array from my custom C++ runtime library to make sure that global constructors and such are run
after this its device initialization.
clocks, gpio, modes, flash, etc.
on some platforms you will have a very slow clock out of reset and you will want to make sure to lock the pll before running all the initialization.
final thing depends on whether you want to use an OS or not, but initializing the OS interrupt source, and then start the OS.
>>
>>109089140
for ESP32, theres decent support for emulation in QEMU
this opens a lot of possibilities, unlimited hardware breakpoints for one
regardless, much of the startup and init code might be unnecessary since the compiler gives you this already.
But I think its interesting, and it gives you more control and insight into what is happening and when
>>
>>109082514
This. Get an Arduino which comes with a DIP package ATmega328P (picrel) and watch these videos. They cover everything you need to know to go from Arduino -> bare metal.

https://youtube.com/playlist?list=PLNyfXcjhOAwOF-7S-ZoW2wuQ6Y-4hfjMR
>>
File: blinkie_esp32.webm (2.44 MB, 400x200)
2.44 MB
2.44 MB WEBM
>>>/diy/2973477



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.