Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 flash error with segment count error using esptool.py from esp-idf #20980

Closed
rolandma opened this issue Nov 25, 2019 · 5 comments · Fixed by #27070
Closed

ESP32 flash error with segment count error using esptool.py from esp-idf #20980

rolandma opened this issue Nov 25, 2019 · 5 comments · Fixed by #27070
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale

Comments

@rolandma
Copy link
Contributor

After successfully build a project for ESP32, when running for west flash, there's an error:
west flash -d build/ --skip-rebuild --esp-device /dev/ttyS0
-- west flash: using runner esp32
-- runners.esp32: Converting ELF to BIN
esptool.py v2.9-dev

A fatal error occurred: Invalid segment count 17 (max 16). Usually this indicates a linker script problem.
ERROR: command exited with status 2: /usr/bin/python3 /esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 elf2image /zephyr/samples/build/zephyr/zephyr.elf

@rolandma rolandma added the bug The issue is a bug, or the PR is fixing a bug label Nov 25, 2019
@rolandma
Copy link
Contributor Author

Okay, by changing the esptool.py segments >17 will fix the flashing error, but seems to me the code didn't really run.
def verify(self):
if len(self.segments) > 17:
raise FatalError('Invalid segment count %d (max 16). Usually this indicates a linker script problem.' % len(self.segments))

@rolandma rolandma reopened this Dec 2, 2019
@rolandma rolandma changed the title ESP32 flash error ESP32 flash error with segment count error using esptool.py from esp-idf Dec 2, 2019
@rolandma
Copy link
Contributor Author

rolandma commented Dec 2, 2019

I would like to re-open this issue, not because I can't flash it onto the ESP32-wroom-32D dev kit, but because even if I change the esptool.py script to flash it, no sample project will run other than "hello-world". which is not very helpful. I compiled several samples, and all compiled successfully, but none will run on the target board. I tried at least these 4 samples, and managed to compile all of them, but when using 'west flash -d build/ --skip-rebuild --esp-device /dev/ttyS0', the 'hello-world' sample can flash and start the zephyr os, but all others won't flash.

  1. samples/net/vlan
  2. sample/net/mqtt_publisher
  3. sample/net/lwm2m_client
  4. sample/net/wifi

@Skallwar
Copy link

This is due to the fact that esptool create an app image from the ELF sections. And there is more than 16 of them. This might be possible to fix this in the ESP32 linker script by merging sections

@dcpleung
Copy link
Member

Network subsystem and kernel objects utilize linker sections extensively to group data together. The definitions for those sections are common to all arch/SoCs/boards. We could re-implement them in ESP32's linker script by grouping them into fewer sections, but this will increase maintenance as changes to common scripts will need to be re-implement in ESP32's.

dcpleung added a commit to dcpleung/zephyr that referenced this issue Aug 11, 2020
When converting ELF to a flashable image, the esptool can only
process up to 16 ELF sections. Zephyr has been happily grouping
similar objects into linker sections which can easily go over
esptool's limit. This patch consolidates the kernel, net, log,
and shell objects into their own sections.

Also remove the app_noinit section as no one is emitting
anything into that section, and it's not being used by other
arch/SoC/boards in Zephyr.

Fixes zephyrproject-rtos#20980

Signed-off-by: Daniel Leung <[email protected]>
@github-actions
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Sep 21, 2020
mahavirj pushed a commit to mahavirj/zephyr that referenced this issue Sep 24, 2020
When converting ELF to a flashable image, the esptool can only
process up to 16 ELF sections. Zephyr has been happily grouping
similar objects into linker sections which can easily go over
esptool's limit. This patch consolidates the kernel, net, log,
and shell objects into their own sections.

Also remove the app_noinit section as no one is emitting
anything into that section, and it's not being used by other
arch/SoC/boards in Zephyr.

Fixes zephyrproject-rtos#20980

Signed-off-by: Daniel Leung <[email protected]>
@github-actions github-actions bot closed this as completed Oct 5, 2020
andrewboie pushed a commit that referenced this issue Oct 13, 2020
When converting ELF to a flashable image, the esptool can only
process up to 16 ELF sections. Zephyr has been happily grouping
similar objects into linker sections which can easily go over
esptool's limit. This patch consolidates the kernel, net, log,
and shell objects into their own sections.

Also remove the app_noinit section as no one is emitting
anything into that section, and it's not being used by other
arch/SoC/boards in Zephyr.

Fixes #20980

Signed-off-by: Daniel Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants