Open bartgrantham opened 1 year ago
try this:
diff --git a/examples/blinky/main.c b/examples/blinky/main.c index f4766c8..660e7db 100644 --- a/examples/blinky/main.c +++ b/examples/blinky/main.c @@ -4,6 +4,7 @@ static int led_pin = LED1; // To override: make EXTRA_CFLAGS=-DLED1=5 static int led_state = 0;
int main(void) {
wdt_disable(); gpio_output(led_pin);
for (;;) {
I spent many hours now, making bins and flashing them. As mentioned elsewhere, esputil does not work for me at all, and I've been using esptool.
I can flash arduino crap with it, but every attempt to flash blinky is generally just ignored, and the device continues to run old code in higher memory (since blinky is so small...). Otherwise it just keeps resetting and printing repeating crap.
OK, crashing for hours in slightly different ways I found a stable recipe that works...xs
To generate firmware.bin:
esptool.py --chip esp32 elf2image --dont-append-digest firmware.elf
To flash it:
esptool.py -p /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 firmware.bin
That was truly painful.
esptool can also check a bin file for corruption or incorrectness. That is how I found out that esputil was screwing me for hours - it generated an invalid checksum or something.
I added a few useful targets in the mdk/esp32/build.mk file:
$(PROG).bin: $(PROG).elf $(ESPTOOL)
$(ESPTOOL) --chip $(ARCH) elf2image --dont-append-digest $(PROG).elf
check: $(PROG).bin
$(ESPTOOL) --chip $(ARCH) image_info --version 2 $(PROG).bin
flash: $(PROG).bin
$(ESPTOOL) --chip $(ARCH) --port $(PORT) --baud 921600 --before default\
_reset --after hard_reset write_flash -fm dio --flash_freq 80m --flash_size 4MB\
$(FLASH_ADDR) $(PROG).bin
And many thanks for a great project! I was really getting sick of Arduino, and the Espressif environment is an enormous vat of excrement.
mdk is actually cool!
@NilsBe This did turn off the watchdog timer, which prevented it from resetting. But there was still no blinking LED.
Which made me wonder: which LED is supposed to blink here? The ws2812? The little red power LED? @cpq Is this example intended to work on this board?
I just realized that the LED that was supposed to light up was the one I was supposed to connect to pin 2. I wired up a pin and now it works. It does need wdt_disable()
though, or the watchdog will keep resetting the board before it can blink.
@bartgrantham I suggest https://github.com/cpq/bare-metal-programming-guide/tree/main/templates/blinky/esp32-c3
It has systick interrupt implemented as well, which gives better timing capability
I'll definitely look into that. Is that repo more up to date than this one? Looks like it. Is this repo deprecated?
This is not deprecated, it is just the other one is more advanced at this point.
The code builds ok but it appears to crash immediately and
esptool monitor
throws an odd error:And it repeats the last 15 lines indefinitely. The gibberish is masking debugging output from
expect
, I think?examples/ws2812
works fine. FWIW, this is on macOS Ventura 13.1, runningpodman
instead ofdocker
, and I built the image fromDockerfile
example in theREADME.md
.examples/button
also works.examples/bme280
does not, but I am not sure it was expected to.