[FluidNC PR#1591] Remove esptool –chip option when not necessary

未分类 bolang 4个月前 (10-14) 40次浏览

Issue #1591 | 状态: 进行中 | 作者: PhiJu5 | 创建时间: 2025-10-08


From espressif esptool ESP32 and ESP32S3 ‘Basic Options”:

If no -c option or ESPTOOL_CHIP value is specified, esptool automatically detects the chip type when connecting.
Binary image generation commands, such as elf2image or merge-bin, require the chip type to be specified.

So remove esptool –chip option when not necessary.
And then remove unecessary erases3.bat and install-fss3.bat in install_scripts.

After a wifi_s3 build

py generate_vcxproj.py
pio run -e wifi_s3

.pio\build\wifi_s3\.sconsign311.dblite
constains expected –chip esp32s3 elf2image

After a wifi build
.pio\build\wifi\.sconsign311.dblite
constains expected –chip esp32 elf2image


评论 (8)

#1 – MitchBradley 于 2025-10-08

What happens when someone then installs the wrong version on the wrong chip?


#2 – PhiJu5 于 2025-10-08

Hum, this another topic. There is espchipinfo() API.

espchipinfot outinfo;

espchipinfo(&out_info);

out_info.model gives the model

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/miscsystemapi.html#CPPv416espchipmodelt

When you build for S3, there should be some #define esp type available (ex arduino CONFIGIDFTARGET_ESP32
CONFIGIDFTARGET_ESP32S3) or you can define one globaly in the s3 build part.

Than in main() first check build against model,
print/output the found model and the build model do not match.

ex

#ifdef CONFIGIDFTARGET_ESP32
if (outinfo.model != CHIPESP32) {
error
while(1);
}
#endif
#ifdef CONFIGIDFTARGET_ESP32S3
if (outinfo.model != CHIPESP32S3) {
error
while(1);
}
#endif*


#3 – MitchBradley 于 2025-10-08

The second stage bootloader is at different addresses on ESP32 and ESP32-S3, so if you install the wrong image, it will not even start running.


#4 – PhiJu5 于 2025-10-08

It tooks me time to install win11 ESPIDF and found an ESP32S3 and ESP32 in my messy Arduino boxes.

It doesn’t change the fact that –chip is not needed with write_flash according espressif documentation.
Let’s verify:

F:\ESPIDF\examples\get-started\blink>
idf.py set-target esp32s3
idf.py build
idf.py -p COM12 flash
and here copied the esptool.py flash command from output

now in build, let’s reflash with pasted command

esptool.py –chip esp32s3 -p COM12 -b 460800 –before=defaultreset –after=hardreset writeflash –flashmode dio –flashfreq 80m –flashsize 2MB 0x0 bootloader/bootloader.bin 0x10000 blink.bin 0x8000 partition_table/partition-table.bin

esptool.py v4.10.0
Serial port COM12
Connecting….
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
Crystal is 40MHz
MAC: dc:da:0c:10:c0:a8
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 460800
Changed.
Configuring flash size…
Flash will be erased from 0x00000000 to 0x00005fff…
Flash will be erased from 0x00010000 to 0x0004afff…
Flash will be erased from 0x00008000 to 0x00008fff…
SHA digest in image updated
Compressed 20928 bytes to 13322…
Wrote 20928 bytes (13322 compressed) at 0x00000000 in 0.5 seconds (effective 351.6 kbit/s)…
Hash of data verified.
Compressed 238304 bytes to 126775…
Wrote 238304 bytes (126775 compressed) at 0x00010000 in 3.0 seconds (effective 630.1 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 103…
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 738.0 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…

Now same with “–chip esp32s3” removed

esptool.py -p COM12 -b 460800 –before=defaultreset –after=hardreset writeflash –flashmode dio –flashfreq 80m –flashsize 2MB 0x0 bootloader/bootloader.bin 0x10000 blink.bin 0x8000 partition_table/partition-table.bin

esptool.py v4.10.0
Serial port COM12
Connecting….
Detecting chip type… ESP32-S3
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
Crystal is 40MHz
MAC: dc:da:0c:10:c0:a8
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 460800
Changed.
Configuring flash size…
Flash will be erased from 0x00000000 to 0x00005fff…
Flash will be erased from 0x00010000 to 0x0004afff…
Flash will be erased from 0x00008000 to 0x00008fff…
SHA digest in image updated
Compressed 20928 bytes to 13322…
Wrote 20928 bytes (13322 compressed) at 0x00000000 in 0.5 seconds (effective 354.5 kbit/s)…
Hash of data verified.
Compressed 238304 bytes to 126775…
Wrote 238304 bytes (126775 compressed) at 0x00010000 in 3.0 seconds (effective 634.5 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 103…
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 770.0 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…

There is no difference. And the flash without –chip is ok. As described in the documentation for write_flash

Now with an ESP32
idf.py set-target esp32
idf.py build
idf.py -p COM5 flash
copy the flash command from output

Now in build paste and remove –chip esp32

esptool.py -p COM5 -b 460800 –before=defaultreset –after=hardreset writeflash –flashmode dio –flashfreq 40m –flashsize 2MB 0x1000 bootloader/bootloader.bin 0x10000 blink.bin 0x8000 partition_table/partition-table.bin

esptool.py v4.10.0
Serial port COM5
Connecting….
Detecting chip type… ESP32
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 7c:9e:bd:e3:40:48
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 460800
Changed.
Configuring flash size…
Flash will be erased from 0x00001000 to 0x00007fff…
Flash will be erased from 0x00010000 to 0x0003dfff…
Flash will be erased from 0x00008000 to 0x00008fff…
SHA digest in image updated
Compressed 25968 bytes to 16362…
Wrote 25968 bytes (16362 compressed) at 0x00001000 in 0.9 seconds (effective 229.5 kbit/s)…
Hash of data verified.
Compressed 187056 bytes to 100924…
Wrote 187056 bytes (100924 compressed) at 0x00010000 in 2.9 seconds (effective 510.4 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 103…
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 288.5 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…
PS F:\ESPIDF\examples\get-started\blink\build>

and it works on ESP32.

And we see the addresses differences:

ESP32
esptool.py -p COM5 -b 460800 –before=defaultreset –after=hardreset writeflash –flashmode dio –flashfreq 40m –flashsize 2MB 0x1000 bootloader/bootloader.bin 0x10000 blink.bin 0x8000 partition_table/partition-table.bin
ESP32S3
esptool.py -p COM12 -b 460800 –before=defaultreset –after=hardreset writeflash –flashmode dio –flashfreq 80m –flashsize 2MB 0x0 bootloader/bootloader.bin 0x10000 blink.bin 0x8000 partition_table/partition-table.bin

The fact that install-wifi_s3.bat and install-wifi.bat have same addresses in the branch (and should not ?) is another topic.

web installer should detect chip model (with esptool output, parse Detecting chip type… ESP32[-S3]) and build and use scripts accordling, and refuse if it’s not ESP32 or not (futur ?) ESP32S3.

But –chip is not needed in this patch listed files.

Voila.


#5 – PhiJu5 于 2025-10-08

!diffs


#6 – MitchBradley 于 2025-10-08

Would you like to be the owner of the install scripts and take responsibility for helping users who have install problems? I would gladly cede responsibility for supporting them.


#7 – PhiJu5 于 2025-10-08

No thanks.


#8 – PhiJu5 于 2025-10-08

Tested manually that –chip is not needed on real fluidnc .bin ESP32 and ESP32S3

ESP32
From ESPIDF powershell
py generate_vcxproj.py
pio run -t clean
pio run

Use same arguments as in install-wifi.bat without –chip
E:\Github\FluidNC\.pio\build\wifi>
esptool.py -p COM5 –baud 921600 –before defaultreset –after hardreset writeflash -z –flashmode dio –flashfreq 80m –flashsize detect 0x1000 bootloader.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x8000 partitions.bin

Grbl [FluidNC s3test (S3OldCompiler-15dbf298-dirty) (wifi) ‘$’ for help]
ok

ESP32S3
py generate_vcxproj.py
pio run -t clean
pio run -e wifi_s3

Use same arguments as in install-wifi_s3.bat without –chip
E:\Github\FluidNC\.pio\build\wifi_s3

an adress in install-wifi_s3.bat is not working, 0x1000 bootloader.bin, has to be changed in 0x0 bootloader.bin (in another patch)
and I had to copy boot_app0.bin from official fluidnc-v3.9.9-win64 (is missing in S3OldCompiler)

esptool.py -p COM12 –baud 921600 –before defaultreset –after hardreset writeflash -z –flashmode dio –flashfreq 80m –flashsize detect 0x0 bootloader.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x8000 partitions.bin

ESP-ROM:esp32s3-20210327
[MSG:INFO: uart_channel0 created]
[MSG:RST]
[MSG:INFO: FluidNC s3test (S3OldCompiler-15dbf298-dirty) https://github.com/PhiJu5/FluidNC.git%5D
[MSG:INFO: Local filesystem type is littlefs]
[MSG:INFO: Configuration file:config.yaml]
[MSG:INFO: Machine Default (Test Drive no I/O)]
[MSG:INFO: Board None]
[MSG:INFO: Stepping:Timed Pulse:4us Dsbl Delay:0us Dir Delay:0us Idle Delay:255ms]
[MSG:INFO: Axis count 3]
[MSG:INFO: Axis X (-1000.000,0.000)]
[MSG:INFO: Motor0]
[MSG:INFO: Axis Y (-1000.000,0.000)]
[MSG:INFO: Motor0]
[MSG:INFO: Axis Z (-1000.000,0.000)]
[MSG:INFO: Motor0]
[MSG:INFO: Kinematic system: Cartesian]
[MSG:INFO: AP SSID FluidNC IP 192.168.0.1 mask 255.255.255.0 channel 1]
[MSG:INFO: AP started]
[MSG:INFO: WiFi on]
[MSG:INFO: Captive Portal Started]
[MSG:INFO: HTTP started on port 80]
[MSG:INFO: Telnet started on port 23]

Grbl [FluidNC s3test (S3OldCompiler-15dbf298-dirty) (wifi) ‘$’ for help]
ok


原始Issue: https://github.com/bdring/FluidNC/pull/1591

喜欢 (0)