Skip to content

ESP32: Wrong library used for "SD.h" #1548

Closed
@AndreKR

Description

@AndreKR

Describe the bug
Compiling a sketch that includes <SD.h> for ESP32 fails with a "Architecture or board not supported" error because the wrong library is used.

To Reproduce

  1. This might be a relevant step: I have Arduino 1.8 installed normally and I am running Arduino 2.0 from the ZIP (not installed).
  2. Install the ESP32 core via the board manager
  3. Set the board to for example "ESP32 Dev Module"
  4. Compile this sketch: (The one line is enough to reproduce the issue.)
#include <SD.h>

Actual behavior
An error happens:

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:524:2: error: #error Architecture or board not supported.
 #error Architecture or board not supported.
  ^
Multiple libraries were found for "SD.h"
 Used: C:\Program Files (x86)\Arduino\libraries\SD
 Not used: C:\Users\andre\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD
Compilation error: Error: 13 INTERNAL: exit status 1

Expected behavior
Good question. I think the problem is there's an SD library bundled with the IDE and there is one bundled with the core and the one bundled with the IDE is used. Note that I have both Arduino 1.8 and Arduino 2.0 installed and I think the "Used" library comes from Arduino 1.8.

The error happens only in Arduino 2.0, so how does Arduino 1.8 handle this? I would assume the library from the core should take precedence over the library from the IDE?

Desktop (please complete the following information):

  • OS: Windows
  • Version: 2.0.0-beta.12

Activity

self-assigned this
on Nov 13, 2021
per1234

per1234 commented on Nov 13, 2021

@per1234
Contributor

Hi @AndreKR. Thanks for your report.

This is caused by an intentional change to the Arduino CLI tool that handles the compilation process for the Arduino IDE. The full details on that change, and how it can cause the loss of priority for the platform bundled libraries in rare cases such as the one you experienced, are provided here: #1292

The fix for that has already been made in the ESP32 boards platform (espressif/arduino-esp32@de66c39), which was released in ESP32 boards 2.0.0. However, you are using an older version of the ESP boards platform (1.0.6), which doesn't have that change.

So you can pick one of the following options for fixing this:

  • Use the Arduino IDE Boards Manager to update to ESP32 boards platform version 2.0.0 or later.
  • Manually backport the fix by changing line 1 of this file:
    C:\Users\andre\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD\library.properties
    
    from this:
    name=SD(esp32)
    
    to this:
    name=SD
    
AndreKR

AndreKR commented on Nov 13, 2021

@AndreKR
Author

So you can pick one of the following options for fixing this:

  • Use the Arduino IDE Boards Manager to update to ESP32 boards platform version 2.0.0 or later.

That was the first thing I tried, but I only got version 1.0.6.

In Arduino IDE 1.8:

image

In Arduino IDE 2.0:

image

per1234

per1234 commented on Nov 13, 2021

@per1234
Contributor

That was the first thing I tried, but I only got version 1.0.6.

This is because Arduino IDE 2.x only shows the already installed version of the platform if you don't have the platform's package index URL in your preferences. Arduino IDE 2.x has a completely different preferences storage system from the classic Arduino IDE, so the preferences from the classic Arduino IDE are not used by Arduino IDE 2.x.

Please try this:

  1. Select File > Preferences from the Arduino IDE 2.x menus.
  2. In the "Preferences" dialog that opens, add the following URL to the "Additional Boards Manager URLs" field:
    https://github.com/raw/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    
    If there are already URLs in the "Additional Boards Manager URLs" field, separate them with commas (,).
  3. Close all Arduino IDE 2.x windows.
  4. Start the Arduino IDE 2.x
    (restart is required because, due to a bug, Arduino IDE 2.x doesn't otherwise recognize changes to the "Additional Boards Manager URLs" preference)

Now you will be able to use Boards Manager to update the ESP32 boards platform to the latest version. After doing that, the correct SD library will be used.

AndreKR

AndreKR commented on Nov 13, 2021

@AndreKR
Author

That worked.

Using the Preferences dialog also switched the IDE to the light theme. :)

By the way, why is the 2.0 version ignored by Arduino IDE 1.8, I don't see any obvious differences in the JSON?

AndreKR

AndreKR commented on Nov 13, 2021

@AndreKR
Author

By the way, why is the 2.0 version ignored by Arduino IDE 1.8, I don't see any obvious differences in the JSON?

Ah, never mind, I was using a different board URL in Arduino IDE 1.8: https://dl.espressif.com/dl/package_esp32_index.json

per1234

per1234 commented on Nov 13, 2021

@per1234
Contributor

Using the Preferences dialog also switched the IDE to the light theme. :)

This bug is being tracked at arduino/arduino-ide#530

mathemaphysics

mathemaphysics commented on Jul 5, 2024

@mathemaphysics
locked as resolved and limited conversation to collaborators on Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

conclusion: invalidIssue/PR not validtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @AndreKR@mathemaphysics@per1234

      Issue actions

        ESP32: Wrong library used for "SD.h" · Issue #1548 · arduino/arduino-cli