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

MacOS Monterey: bad CPU type in executable #106

Open
DasBlackfur opened this issue Jun 24, 2022 · 13 comments
Open

MacOS Monterey: bad CPU type in executable #106

DasBlackfur opened this issue Jun 24, 2022 · 13 comments

Comments

@DasBlackfur
Copy link

DasBlackfur commented Jun 24, 2022

Heyho, I tried to setup HoodLoader2 + HID-Project and the installation went alright but if I now try to compile an example sketch I get this error in the output log:
Compilation error: fork/exec /Users/blackfur/Library/Arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/bin/avr-g++: bad CPU type in executable

The issue seems to be that avr-gcc in version 4.8.1 is not available as a x86_64 binary and thus cannot be executed on any Mac running MacOS 10.15 or higher.

Do you have any idea what I could try?

@DasBlackfur
Copy link
Author

Asking more specifically why is HoodLoader stuck on such a old version of avr-gcc

@NicoHood
Copy link
Owner

Maybe the board file needs an update? Does arduino use newer versions in the meantime?

I just had a quick look, but I cannot see that this error comes from this repository. Does compiling for other devices work for you?

@DasBlackfur
Copy link
Author

Maybe the board file needs an update? Does arduino use newer versions in the meantime?

This probably, arduino currently uses 7.3.0-atmel3.6.1-arduino7 with the vanilla Uno board.

I just had a quick look, but I cannot see that this error comes from this repository. Does compiling for other devices work for you?

Well the issue is that arduino doesn't offer a 64 bit version of 7 year old compiler. Yes compiling for other devices works.

I know the issue, (since this is a common bs problem on macOS) but I know too little about arduino IDE board files to do anything about it.

@DasBlackfur
Copy link
Author

Another quick look the issue lies in this file: https://raw.githubusercontent.com/NicoHood/HoodLoader2/master/package_NicoHood_HoodLoader2_index.json under toolsDependencies there is the entry "version": "4.8.1-arduino5"

@NicoHood
Copy link
Owner

Thanks, that helped.

@per1234 Could you please have a look? I think you have helped me packaging this, can we update it?

@DasBlackfur
Copy link
Author

I did it, have a look at the most recent release :D https://github.com/TheBlackfurGuy/dumpster-fire/releases
Just replaced the old version with the one the most recent version of the arduino board definition uses.

@DasBlackfur
Copy link
Author

Everything works wonderfully now. I'll make sure to buy you a coffee :)

@per1234
Copy link
Contributor

per1234 commented Jun 25, 2022

The version numbers of the arduino:avr-gcc and arduino:avrdude tool dependencies selected by @TheBlackfurGuy are the ones used in the most recent release of the official "Arduino AVR Boards" platform, so I think updating to them is a good idea.

However, I don't think the specific change made in https://github.com/TheBlackfurGuy/dumpster-fire/releases/download/dumpster-v3/package_NicoHood_HoodLoader2_index.json (modifying the existing HoodLoader2 2.0.5 release) is the right approach. The correct approach is to make a new release. The most concrete reason is that this will push the update out to all the existing users via the Arduino Boards Manager system, which would not happen if you only modify the existing release. In addition, it is really not good development practices to make changes to an existing release. If you don't have any changes on the platform files themselves you want to release, you could simply reuse the existing content of the 2.0.5 release, with the only change being the updated tool dependency versions.

These are very significant bumps, so some validation would be a good idea. Offhand, I can't think of
any issues to be concerned about, but definitely worth at least running some "smoke test" compilations and uploads to make sure nothing is completely broken.

@DasBlackfur
Copy link
Author

Yeah it was just a quick test to see if it even works or if gcc broke for 16u2 in the meantime.

@NicoHood
Copy link
Owner

@per1234 Thanks for those tips! Could you help me package the zip file that must be uploaded in order to make the board manager compatible? I think we need to bump the versions via pr, tag a new release and then attach the zip files? I dont remember good how it is done.

@per1234
Copy link
Contributor

per1234 commented Jul 2, 2022

Here is the release procedure:

Make release

The GitHub releases system is used because it allows attaching "assets" files to a Git tag, which is used for distribution of the release archive rather than having to check it into the repository.

  1. Decide the version number of the new release.
  2. Update the version value in platform.txt to the new version number:
    version=2.0.5
  3. Open the GitHub release creation page:
    https://github.com/NicoHood/HoodLoader2/releases/new
  4. Click on the "Choose a tag" menu.
  5. Type the version number into the field.
  6. Select "+ Create a new tag: <tag name> on publish" from the dropdown menu.
  7. Click the Publish release button.

Make release archive

This is the file containing the platform release, which will be downloaded by the Arduino Boards Manager.

  1. Make the release archive:
    TAG_NAME="<tag name>"
    git clone --branch $TAG_NAME https://github.com/NicoHood/HoodLoader2
    cd HoodLoader2/
    ARCHIVE_NAME="${TAG_NAME}-boards_manager.zip"
    zip -9 -r "$ARCHIVE_NAME" avr/
    
  2. Open the GitHub release page:
    https://github.com/NicoHood/HoodLoader2/releases/latest
  3. Click the pencil icon near the top right corner of the release page.
  4. Click on "Attach binaries by dropping them here or selecting them.".
  5. Select the release archive file you created.
  6. Click the Open button.
  7. Click the Update release button.

Make package index entry

This is the data file Arduino Boards Manager uses for platform installations and updates.

  1. Determine the checksum of the release archive:
    sha256sum "$ARCHIVE_NAME"
    
  2. Determine the size of the release archive:
    stat --printf="%s" "$ARCHIVE_NAME"
    
  3. Write a package index entry for the release:
    {
      "name": "HoodLoader2",
      "architecture": "avr",
      "version": "TODO_TAG_NAME",
      "category": "Contributed",
      "help": {
        "online": ""
      },
      "url": "https://github.com/NicoHood/HoodLoader2/releases/download/TODO_TAG_NAME/TODO_TAG_NAME-boards_manager.zip",
      "archiveFileName": "TODO_TAG_NAME-boards_manager.zip",
      "checksum": "SHA-256:TODO_CHECKSUM",
      "size": "TODO_SIZE",
      "boards": [
        {"name": "16u2"},
        {"name": "32u2"},
        {"name": "8u2"},
        {"name": "at90usb82"},
        {"name": "at90usb162"},
        {"name": "32u4"},
        {"name": "Uno"},
        {"name": "Mega 2560"}
      ],
      "toolsDependencies": [
        {
          "packager": "arduino",
          "name": "avr-gcc",
          "version": "7.3.0-atmel3.6.1-arduino7"
        },
        {
          "packager": "arduino",
          "name": "avrdude",
          "version": "6.3.0-arduino17"
        }
      ]
    }
  4. Add the entry to the packages.platforms[] key in the package index file:
    https://github.com/NicoHood/HoodLoader2/blob/master/package_NicoHood_HoodLoader2_index.json
  5. Commit and push the package index entry to the GitHub repository.

@hraftery
Copy link

Specifying the link in @per1234 's comment as the "Additional boards manager URLs" resolved the error for me (noting however, that that's not why per1234 provided it!).

For me the error appeared when I tried to use Arduino IDE to Flash the bootloader using Arduino as ISP, on MacOS Sonoma 14.1.1 running on an M1, with the same symptoms described in this issue.

@DasBlackfur
Copy link
Author

@hraftery You are welcome :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants