Downloading Firmware Question

User avatar
mbratch
Posts: 302
Joined: Fri Jun 11, 2021 1:51 pm

Re: Downloading Firmware Question

Postby mbratch » Thu Oct 27, 2022 2:14 am

You could also try `idf.py partition_table` (I think that's the right command... It's in the documentation).

mzincali
Posts: 46
Joined: Wed Jun 08, 2022 7:23 am

Re: Downloading Firmware Question

Postby mzincali » Thu Oct 27, 2022 10:09 am

Ok, I made huge jump in knowledge, but I got stuck again.

I never could get my custom board to output the startup log. I suspect that the configuration of the pins might be suppressing the logging. This could be problem later when I want more of the info, but I'll wait to figure that out later.

I realized that from within VSCode PIO I can type:

pio run -v -t upload

and I get (some output omitted):

Code: Select all

"/Users/mz/.platformio/penv/bin/python" "/Users/mz/.platformio/packages/tool-esptoolpy/esptool.py" --chip esp32c3 --port "/dev/cu.usbmodem14201" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0000 /Users/mz/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32c3/bin/bootloader_qio_80m.bin 0x8000 /Users/mz/Dropbox/PlatformIO/Projects/kinitest/.pio/build/esp32-c3-devkitm-1/partitions.bin 0xe000 /Users/mz/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 .pio/build/esp32-c3-devkitm-1/firmware.bin
esptool.py v3.3
Serial port /dev/cu.usbmodem14201
Connecting...
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: a0:76:4e:46:14:fc
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000f1fff...
Flash params set to 0x022f
Compressed 12912 bytes to 9261...
Writing at 0x00000000... (100 %)
Wrote 12912 bytes (9261 compressed) at 0x00000000 in 0.4 seconds (effective 283.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 129...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (129 compressed) at 0x00008000 in 0.1 seconds (effective 340.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 509.1 kbit/s)...
Hash of data verified.
Compressed 925008 bytes to 553205...
So, now I had the location of the missing files that are the bootloader and the boot_app0.

Next, I found a Windows laptop. I installed the Espressif ESP32 Download Tool. I configured it like this:
Screenshot_20221027_052444.png
Screenshot_20221027_052444.png (43.86 KiB) Viewed 3448 times
I thought for sure that this would do the trick, but the ESP32 keeps crashing and rebooting. I also tried 80Mhz for the SPI speed but same. The one thing that I am finding that is different, is this:

Download Tool says:

Code: Select all

Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Compressed 12912 bytes to 9259...
Compressed 3072 bytes to 129...
Compressed 8192 bytes to 47...
Compressed 925008 bytes to 553205...

 is stub and send flash finish
while pio run -v -t upload says:

Code: Select all

Compressed 12912 bytes to 9261...
Compressed 3072 bytes to 129...
Compressed 8192 bytes to 47...
Compressed 925008 bytes to 553205...
[/code]
One compresses the bootloader to 9259 bytes and the other to 9261 bytes. Is this the problem? I'm not sure where to look at this point.

mzincali
Posts: 46
Joined: Wed Jun 08, 2022 7:23 am

Re: Downloading Firmware Question

Postby mzincali » Thu Oct 27, 2022 10:13 am

mbratch wrote:
Thu Oct 27, 2022 2:14 am
You could also try `idf.py partition_table` (I think that's the right command... It's in the documentation).
I don't seem to have idf.py installed in the right place:

Code: Select all

kinitest % idf.py partition_table
zsh: command not found: idf.py

mzincali
Posts: 46
Joined: Wed Jun 08, 2022 7:23 am

Re: Downloading Firmware Question

Postby mzincali » Thu Oct 27, 2022 10:14 am

mbratch wrote:
Thu Oct 27, 2022 2:14 am
You could also try `idf.py partition_table` (I think that's the right command... It's in the documentation).
I don't seem to have idf.py installed in the right place:
kinitest % idf.py partition_table
zsh: command not found: idf.py

User avatar
mbratch
Posts: 302
Joined: Fri Jun 11, 2021 1:51 pm

Re: Downloading Firmware Question

Postby mbratch » Thu Oct 27, 2022 1:04 pm

If you are using a custom partition table, then you would have configured the SDK to use a csv file that you created. You should share that if that's the case. If not, then the system will use the default partition table. There are defaults for the program and nvs store as well. This is described in the ESP-IDF documentation.

As described in the documentation, here is what the default is for a single factory image (no OTA):

Code: Select all

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 1M,
The default location for the partition table is 0x8000 as described in the document. In addition, the default location for the bootloader is 0x1000. This is described in the bootloader documentation. If you did not create a custom partition table and configure your ESP-IDF to use it, then the above is what it will use. Your programming using the tool needs to be consistent with that. Your partition table and app seem to be assigned the correct address, but your boot loader is not. I don't know what your boot_app0.bin is.

mzincali
Posts: 46
Joined: Wed Jun 08, 2022 7:23 am

Re: Downloading Firmware Question

Postby mzincali » Sat Oct 29, 2022 9:01 pm

I got over this issue but I can't really tell why it wasn't originally working.

In PlatformIO I had a setting of `board_build.partitions = min_spiffs.csv`

That would then use these files and offsets for the download to the board:

Code: Select all

0x0000 bootloader_qio_80m.bin
0x8000 partitions.bin
0xe000 boot_app0.bin
0x10000 firmware.bin
(These files seem to make sense, especially since the Download Tool includes the bootloader and the boot_app0 files in a folder along with other files. I still haven't figured out what boot_app0 does).

The problem is that when things work on my Mac, using platformio, the compressed sizes are:

Code: Select all

Compressed 12912 bytes to 9261...
Compressed 3072 bytes to 129...
Compressed 8192 bytes to 47...
Compressed 925008 bytes to 553205...
When using the Download Tool on Windows:

Code: Select all

Compressed 12912 bytes to 9259...
Compressed 3072 bytes to 129...
Compressed 8192 bytes to 47...
Compressed 925008 bytes to 553205...
Those 2 differing bytes seem to make a big difference.

I decided to try something else. I changed my partition settings to `board_build.partitions = no_ota.csv`, that results in a different bootloader file, but on both platforms it compressed to the same thing:

Code: Select all

Compressed 12944 bytes to 9297...
I'm still not sure what the issue was but I've managed to get my two offshore assembly teams to install my test firmware. That's success for now. I'm trying to learn more about the firmware process and the location each piece on the flash etc.

Thanks for all the help, @mbratch!! I really appreciate it.

(You use Espressif IDF and not PlatformIO, correct?)

Who is online

Users browsing this forum: tocs03 and 70 guests