https://toitlang.org/ logo
Building a single binary .bin to flash to a device
# help
a
In order to get a single binary easily for flashing on a device, we have flashed it to a device and read it back. Something like... -
jag toit tool firmware --envelope=.\ble.envelope flash -pCOM70
-
esptool.exe -p COM70 -b 460800 read_flash 0 ALL ble_adv_500.bin
Is there an easy way to get and or reconstruct such as binary using the toit firmware commands that I am missing?
TLDR this is basically for trying to make using https://docs.espressif.com/projects/esp-test-tools/en/latest/esp32/production_stage/tools/flash_download_tool.html as simple as possible, and being able to provide a single binary file for position 0
k
jag toit tool firmware extract --help
So something like
jag toit tool firmware --envelope=ble.envelope extract --format=binary -o ble_adv_500.bin
?
a
Perhaps looks at his notes from a few weeks back
Yes, I think thats basically what I want, and I must have also found it, I'm now wondering why I might have decided that didnt work? It was potentially something like the bin didnt work / didnt appear to have everything in it, but let me retry shortly and see
So I tried flashing this binary (from the extract command) and post flash I just get something like this
Copy code
> jag monitor
Starting serial monitor of port 'COM14' ...
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x15 (USB_UART_HPSYS),boot:0x6f (SPI_FAST_FLASH_BOOT)
Saved PC:0x4080082e
SPIWP:0xee
mode:DIO, clock div:2
load:0x42130020,len:0x489c4
load:0x40800000,len:0x762c
load:0x42000020,len:0x12a814
Invalid image block, can't boot.
ets_main.c 331
vs if I flash the envelope to the device, and read the flash back into a bin file, then use that with the esp flashing tool, it works
k
Interesting.
a
I wonder what the different between the 2 bin files looks like, lemme have a look
k
I wonder if we can repro this on an ordinary esp32.
a
So the one downloaded from the device is 4096KB (whole flash size), vs 1644KB for the extract one. and it looks like there is a bucnh of stuff at the start missing? https://cdn.discordapp.com/attachments/1448352717310529679/1448626362645745704/image.png?ex=693bf1ef&is=693aa06f&hm=9854fabee87034b4bd94641143ddcedfa0ad466c0e66c66972f8b93be3fe234c&
left is the esp dump, right is from the extract tool
k
Bootloader?
a
Right, so the bin from the extract I can't just put in position 0? (I thought it might also include bootloader), but the bootloader is only added as part of
jag flash
?
What would be neat is basically some ourput or dump from the flash command, so i could add -o full.bin or such, that gives me a full binary of everything that would be flashed in the correct locations
And yes it looks like bootloader, and liekly the partition table too
k
I would think we add the bootloader also when extracting.
Hmm.
Maybe I'm confusing myself but can you try with
--format=image
?
a
oooh, thats bigger
at a guess thats correct, will try flashing shortly
k
The naming is quite confusing here.
Copy code
- binary: the binary app partition. This format can be used with
          the 'esptool' tool.
        - elf: the ELF file of the executable. This is typically used
          for debugging.
        - ubjson: a UBJSON encoding of the sections of the image.
        - image: a binary image suitable for running on QEMU,
          Wokwi, or for flashing a device. See below.
This is the help for the
--format
option.
We often put images in
.bin
files, which adds to the confusion.
We also use the term image for programs (sometimes).
The "This format can be used with the 'esptool' tool." comment associated with
--format=binary
seems unhelpful.
a
seems I still need to get to sign the CLA? :p
k
Should we mention the right format to use for the instructions around line 640 too?
There we use the "binary image" terminology, which is nicely confusing.