cpq / mdk Goto Github PK
View Code? Open in Web Editor NEWA bare metal SDK for the ESP32 & ESP32C3
License: MIT License
A bare metal SDK for the ESP32 & ESP32C3
License: MIT License
There is no reason to complicate the system, and some people really don't want docker on their system.
Making the Espressif toolchain visible is trivial using their export script. If you want you can check for it in mdk/tools/export.sh and prompt the user if it's not visible.
How the toolchain is maintained should be up to the user anywa y - you can use docker outside the mdk perimetert... I think keeping it clean is a win (for instance, I removed a few lines with docker references, but now I will have endless headaches merging your updates!).
Thanks.
Hi I'd like to get this running on Windows, but am not familiar enough with the intricacies of cross compiling to figure out how to do this I don't have Linux or MacOS.
I figure I do not need Docker for windows as the Espressif IDF is installed. (Similarly the IDF has it's own version of Docker) Would you be able to suggest how to get this compiled on Windows, or point me in the right direction as to how to figure it out myself?
Any plans on adding esp32s3 support?
Hi, I am trying the example/blinky and it seems that it builds with no problem but then it stops after
"esputil flash 0 firmware.bin" and hangs there forever.
firmware.bin is generated with no issues
I tried on two different esp32c3 boards, but the same result. So I am stuck with ideas on what to do next.
What is it waiting for when it is trying to flash the chip?
Where could be my next step in debugging this?
Thank you.
The code builds ok but it appears to crash immediately and esptool monitor
throws an odd error:
podman run -it --rm -v /Users/bart/Code/riscv/mdk/examples/blinky:/Users/bart/Code/riscv/mdk/examples/blinky -v /Users/bart/Code/riscv/mdk:/Users/bart/Code/riscv/mdk -w /Users/bart/Code/riscv/mdk/examples/blinky localhost/gcc-riscv riscv-none-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -pedantic -Wdouble-promotion -fno-common -Wconversion -march=rv32imc -mabi=ilp32 -Os -ffunction-sections -fdata-sections -I. -I/Users/bart/Code/riscv/mdk/esp32c3 /Users/bart/Code/riscv/mdk/esp32c3/boot.c main.c -T/Users/bart/Code/riscv/mdk/esp32c3/link.ld -nostdlib -nostartfiles -Wl,--gc-sections -o firmware.elf
/Users/bart/Code/riscv/mdk/esputil/esputil mkbin firmware.elf firmware.bin
/Users/bart/Code/riscv/mdk/esputil/esputil flash 0 firmware.bin
Using flash params 0x22f
Written firmware.bin, 464 bytes @ 0
/Users/bart/Code/riscv/mdk/esputil/esputil monitor
ESP-ROM:esp32c3-api1-20210207
0,len:0x144
SHA-256 comparison failed:
Calculated: 8d0a8732737dba9127ad398dcaab95b080ef25aad59193ac92b6b66ad65e89�J)�)��5ͯ�ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x4038053e
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fc88000,len:0x60
load:0x40380400,len:0x144
SHA-256 comparison failed:
Calculated: 8d0a8732737dba9127ad398dcaab95b080ef25aad59193ac92b6b66ad65e89d2
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x40380400
LED: 0
ESP-ROM:esp32c3-api1-20210207
...
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, running podman
instead of docker
, and I built the image from Dockerfile
example in the README.md
. examples/button
also works. examples/bme280
does not, but I am not sure it was expected to.
I've been playing around with the blinky example, and even reducing its complexity (i.e. just increasing and printing a number) and it crashes consistently after like 1 second.
It starts counting (without delay up to ~300; with delay of 100ms it gets up to the number 4), then I get the "ESP-ROM:esp32c3-api1-20210207" line and the other stuff you see when it reboots.
Is this a known issue?
I've exported the variables:
$ export MDK=/home/adumont/esp32c3/mdk
$ export PATH=$PATH:$MDK/tools
$ export TOOLCHAIN=riscv32-esp-elf
$ export ARCH=ESP32C3
$ export PORT=/dev/ttyUSB0
$ export PATH=$PATH:/home/adumont/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/
When I run the command to make the blinky example, I get an error when making esputil. Do you know how I could fix it?
$ make -C examples/blinky clean build flash monitor
make: Entering directory '/home/adumont/esp32c3/mdk/examples/blinky'
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c main.c -o build/main.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/boot/boot_ESP32C3.s -o build//home/adumont/esp32c3/mdk/src/boot/boot_ESP32C3.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/init.c -o build//home/adumont/esp32c3/mdk/src/init.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/uart.c -o build//home/adumont/esp32c3/mdk/src/uart.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/log.c -o build//home/adumont/esp32c3/mdk/src/log.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/spi.c -o build//home/adumont/esp32c3/mdk/src/spi.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/tcpip.c -o build//home/adumont/esp32c3/mdk/src/tcpip.o
riscv32-esp-elf-gcc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -fno-common -Wconversion -Os -g3 -ffunction-sections -fdata-sections -march=rv32imc -mabi=ilp32 -I. -I/home/adumont/esp32c3/mdk/src -DESP32C3 -c /home/adumont/esp32c3/mdk/src/malloc.c -o build//home/adumont/esp32c3/mdk/src/malloc.o
riscv32-esp-elf-gcc -Xlinker ./build/main.o ./build//home/adumont/esp32c3/mdk/src/boot/boot_ESP32C3.o ./build//home/adumont/esp32c3/mdk/src/init.o ./build//home/adumont/esp32c3/mdk/src/uart.o ./build//home/adumont/esp32c3/mdk/src/log.o ./build//home/adumont/esp32c3/mdk/src/spi.o ./build//home/adumont/esp32c3/mdk/src/tcpip.o ./build//home/adumont/esp32c3/mdk/src/malloc.o -march=rv32imc -mabi=ilp32 -T/home/adumont/esp32c3/mdk/make/ESP32C3.ld -nostdlib -nostartfiles -Wl,--gc-sections -o build/firmware.elf
riscv32-esp-elf-size build/firmware.elf
text data bss dec hex filename
1040 192 32784 34016 84e0 build/firmware.elf
make -C /home/adumont/esp32c3/mdk/tools esputil
make[1]: Entering directory '/home/adumont/esp32c3/mdk/tools'
cc -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion -Os esputil.c -o ./esputil
esputil.c: In function ‘flash’:
esputil.c:581:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
*(uint32_t *) &buf[0] = n; // Populate initial bytes - size
^
esputil.c:582:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
*(uint32_t *) &buf[4] = seq++; // And sequence numner
^
cc1: all warnings being treated as errors
Makefile:11: recipe for target 'esputil' failed
make[1]: *** [esputil] Error 1
make[1]: Leaving directory '/home/adumont/esp32c3/mdk/tools'
../../make/build.mk:40: recipe for target '/home/adumont/esp32c3/mdk/tools/esputil' failed
make: *** [/home/adumont/esp32c3/mdk/tools/esputil] Error 2
make: Leaving directory '/home/adumont/esp32c3/mdk/examples/blinky'
riscv32-esp-elf-gcc -v:
$ /home/adumont/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc -v
Using built-in specs.
COLLECT_GCC=/home/adumont/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc
COLLECT_LTO_WRAPPER=/home/adumont/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/../libexec/gcc/riscv32-esp-elf/8.4.0/lto-wrapper
Target: riscv32-esp-elf
Configured with: /builds/idf/crosstool-NG/.build/riscv32-esp-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=riscv32-esp-elf --prefix=/builds/idf/crosstool-NG/builds/riscv32-esp-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/riscv32-esp-elf/riscv32-esp-elf --with-headers=/builds/idf/crosstool-NG/builds/riscv32-esp-elf/riscv32-esp-elf/include --with-newlib --enable-threads=no --disable-shared --with-arch=rv32imc --with-abi=ilp32 --with-pkgversion='crosstool-NG 1.24.0.123_64eb9ff' --disable-__cxa_atexit --enable-cxx-flags=-ffunction-sections --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/builds/idf/crosstool-NG/.build/riscv32-esp-elf/buildtools --with-mpfr=/builds/idf/crosstool-NG/.build/riscv32-esp-elf/buildtools --with-mpc=/builds/idf/crosstool-NG/.build/riscv32-esp-elf/buildtools --with-isl=/builds/idf/crosstool-NG/.build/riscv32-esp-elf/buildtools --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-gcov-custom-rtio --enable-libstdcxx-time=yes
Thread model: posix
gcc version 8.4.0 (crosstool-NG 1.24.0.123_64eb9ff)
When I run make -C examples/blinky build flash monitor
It seems to fail at some point with a SHA-256 comparison failed error:
$ make -C examples/blinky build flash monitor
make: Entering directory '/home/adumont/esp32c3/mdk/examples/blinky'
make: Nothing to be done for 'build'.
/home/adumont/esp32c3/mdk/tools/esputil flash 0 ./build/firmware.bin
Using flash params 0x21f
Written ./build/firmware.bin, 1280 bytes @ 0
/home/adumont/esp32c3/mdk/tools/esputil monitor
ESP-ROM:esp32c3-20200918
Build:Sep 18 2020
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fc88000,len:0xc0
load:0x40380400,len:0x410
SHA-256 comparison failed:
Calculated: 808377b4141e41be658a7a3283ccc87337eb7aeca2ff23288867817da5ec1e02
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x40380400
1
0
1
0
1
And the LED isn't blinking. Anything I could try?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.