Digispark code not uploading to arduino. Error message being displayed - arduino

Trying to upload code to a DigiSpark USB in Arduino, but I keep getting this error...
Arduino: 1.8.19 (Mac OS X), Board: "Digispark (Default - 16.5mhz)"
fork/exec /Users/dhibbert/Library/Arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/bin/avr-g++: bad CPU type in executable
Error compiling for board Digispark (Default - 16.5mhz).

AVR is using an executable that is incompatible with your processor but we can trick it by linking to one that works. Run the following commands:
cd ~/Library/Arduino15/packages/arduino/tools/avr-gcc
mv 4.8.1-arduino5 old_4.8.1
ln -s /Applications/Arduino.app/Contents/Java/hardware/tools/avr 4.8.1-arduino5

Related

PlatformIO unable to resolve Keyboard / HID / PluggableUSB dependency?

My development environment consists of a Teensy 3.5, PlatformIO, and CLion. How can I make use of the standard Arduino Keyboard library?
I'm working on a project to convert a previously RS422-based device to USB. Earlier on, I used the (sadly rather horrible) Arduino IDE so I know that my code for when to send which keystrokes should work; the problem is getting the new IDE and compiler to understand the dependencies.
All along, I've been using the Serial interface to provide debug output, so I know that Serial works just fine. Ditto for using the Keyboard library from within the Arduino IDE.
However, after switching to CLion and adapting to the PlatformIO framework, I ran into problems when it came time to include the Keyboard library.
The line
#include <Arduino.h>
resolves to the file ~/.platformio/packages/framework-arduinoteensy/cores/teensy3/Arduino.h which itself seems to simply be a shim for ~/.platformio/packages/framework-arduinoteensy/cores/teensy3/WProgram.h which implements the expected Arduino functionality.
However, the line
#include <Keyboard.h>
resolves to the file ~/.platformio/packages/framework-arduinoteensy/cores/teensy3/Keyboard.h which quite frankly states that it is an empty Keyboard.h file, for compability with Arduino's Keyboard examples and does not implement anything.
I have been trying to find ways of importing the original Arduino library (by way of platformio.ini, but it seems to depend on HID and PluggableUSB that I simply cannot find.
Here is my current platformio.ini file:
[env:teensy35]
platform = teensy
board = teensy35
framework = arduino
; Avoid the Teensy loader gui app
upload_protocol = teensy-cli
lib_deps =
Keyboard
and this is the build output I am getting:
====================[ Build | Production | teensy35 ]===========================
~/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/223.8617.54/bin/cmake/linux/x64/bin/cmake --build ~/code/teensy-axial/cmake-build-teensy35 --target Production -j 6
[1/1] cd ~/code/teensy-axial && platformio -c clion run -eteensy35
FAILED: CMakeFiles/Production ~/code/teensy-axial/cmake-build-teensy35/CMakeFiles/Production
cd ~/code/teensy-axial && platformio -c clion run -eteensy35
Processing teensy35 (platform: teensy; board: teensy35; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy35.html
PLATFORM: Teensy (4.17.0) > Teensy 3.5
HARDWARE: MK64FX512 120MHz, 255.99KB RAM, 512KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy # 1.157.220801 (1.57)
- toolchain-gccarmnoneeabi # 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> [redacted for StackExchange]
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 94 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Keyboard # 1.0.4
Building in release mode
Compiling .pio/build/teensy35/src/AxialKeyboard.cpp.o
Compiling .pio/build/teensy35/src/main.cpp.o
Compiling .pio/build/teensy35/lib882/Keyboard/Keyboard.cpp.o
Compiling .pio/build/teensy35/lib882/Keyboard/KeyboardLayout_da_DK.cpp.o
Compiling .pio/build/teensy35/lib882/Keyboard/KeyboardLayout_de_DE.cpp.o
In file included from .pio/libdeps/teensy35/Keyboard/src/Keyboard.cpp:22:0:
.pio/libdeps/teensy35/Keyboard/src/Keyboard.h:25:17: fatal error: HID.h: No such file or directory
*************************************************************
* Looking for HID.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:HID.h"
* Web > https://registry.platformio.org/search?q=header:HID.h
*
*************************************************************
compilation terminated.
[...]
I have obviously visited the registry as suggested and tried to implement both mitchman631/HID and levi--g/USBLibrarySTM32 but still I end up missing either HID or PluggableUSB dependencies, and I cannot find a PluggableUSB.h file anywhere. Surely, there must be something fundamental I am not seeing?
Amending platformio.ini with the path to the Arduino libraries did not resolve the error.
lib_extra_dirs =
/usr/share/arduino/libraries
so I removed these lines again.
I have also tried enabling the --verbose option by copying the command from the above output:
~/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/223.8617.54/bin/cmake/linux/x64/bin/cmake --verbose --build ~/code/teensy-axial/cmake-build-teensy35
but oddly that results in
CMake Error: Unknown argument --build
even though it should know it:
~/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/223.8617.54/bin/cmake/linux/x64/bin/cmake --help | grep build
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
-B <path-to-build> = Explicitly specify a build directory.
-G <generator-name> = Specify a build system generator.
--build <dir> = Build a CMake-generated project binary tree.
I suspect my question is similar to this one, although my problem is with adding any library.

Error when uploading code to an wifi lora board

When I try to upload code to my board, I get this error:
exec: "python": executable file not found in $PATH
Error compiling for board WiFi LoRa 32.
How do I fix this? (I'm on mac 12.4.)
This Error means That python is Ethier, not installed, or is not in The PATH variable, to fix this try installing python if you are using a Linux machine then follow the instructions on the python website.

How to cross compile Arduino code for esp8266?

I have a Raspberry Pi at a remote location. I have attempted to run the Arduino IDE on that system but it doesn't have enough memory. I would like to compile some code on my Ubuntu desktop, copy the executable file to the Pi and use some utility to load it to an ESP8266 running the OTA software. What I need is to know where the executable is after an IDE compile step and what utility might be used to transfer the file from the Pi to the ESP8266 over the lan.
Any ideas?
Thanks,
Jim.
in arduino ide,
go to, File-> Preferences. Tick mark the boxes for compilation “Show verbose output during: ☑ compilation"
Now You will get the location of all the files generated in arduino console.
See answer by Kinaly Jain. If you upload your code to a local esp, verbose mode will also show you the commands it used to do the upload. You can gather these commands into a script or a makefile to run on the remote Pi.
Thanks to both of the responders. I wanted to try to describe a possible scenario to satisfy my needs. I found out from another post that the "Sketch/Export compiled binary" menu selection will produce a bin file that can be uploaded using a script similar to the one in this page https://github.com/esp8266/Arduino/issues/3553
The script finds the available OTA ports in the network and then uses espota.py to upload the .bin file to the port that you select. I suggest slight update to that script. On my system, espota is in ~/.arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/espota.py and it is now a python3 script. It is executable so you don't need to explicity execute python.
/home/$USER/.arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/espota.py -i $ip -p 8266 --auth="$password" -f "$path" 2> /dev/null && echo -e "Success:\t$ip" || echo -e "Fail: \t$ip" &
I've not tested it yet but I think it'll work with maybe some small tweaks. The avahi-browse utility is in the avahi-utils package on the Raspberry Pi OS. It was not installed by default on RPi OS but it appears to have been on Linux Mint.
To summarize I will run the Arduino IDE on my desktop using the "Export ..." menu, then I'll find the .bin file in the sketch directory and copy it to the Pi. Then I'll use the script mentioned before to hopefully write the bin file to the esp8266 via OTA. I hope this will help someone else with a similar problem.
Thanks again,
Jim.

Extract code (.hex or similar) from arduino Mega ADK on windows 8

I am a new user of Arduino boards. I have an Arduino mega ADK and I have to extract the code that was downloaded on it, because I don't find the source code.
Is there a way to extract the code on Arduino board (such as the .hex file reading the flash memory) without having the source code ?
I use Windows 8.
Thank you very much.
Enrico
Generally, you can find the hex file in a temp directory on your windows machine (assuming it is the machine used to build the code. From the official Arduino docuemntation:
"Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.
The .hex file is the final output of the compilation which is then uploaded to the board. During a "Verify" the .hex file is written to /tmp (on Mac and Linux) or \Documents and Settings\\Local Settings\Temp (on Windows). During upload, it's written to the applet sub-directory of the sketch directory (which you can open with the "Show Sketch Folder" item in the Sketch menu)."
In my experience, I had a bunch of randomly named directories in the location specified above and I had to sort them by date/time and find the one that had my hex file.
Hope that helps!
In Linux this worked for me in Mega 1280:
avrdude -p m1280 -c arduino -P /dev/ttyACM0 -b57600 -U flash:r:flash_backup_file.hex:r
change the baudrate and arduino type.

Reading back ATmega328p program using FTDI Basic

I am trying to read the application I programmed to an ATMega328p atmel processor using the FDTI Basic small usb board, I am using Avrdude 6.0.1 and I am using the following command:
avrdude.exe -p m328p -C avrdude.conf -c 2232HIO -U flash:r:outputTry.bin:r
And I am getting the following error:
avrdude.exe: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.
avrdude.exe: programmer operation not supported
One of my main concerns is the type of programmer I should use if I am using this FDTI Basic.
you need to install ftdi drivers from there:
http://www.ftdichip.com/FTDrivers.htm
Thanks ZMO, but I solved the issue, I used arduino as programmer and my main issue was with the baud rate settings so I used this command:
avrdude.exe -p m328p -C avrdude.conf -c arduino -U flash:r:outputTry.bin:r -b 57600
So anyone who wants to use the FTDI basic (for sure after downloading the drivers) you can use the above command to read the flash back but you have to make sure of the baud rate you used when you uploaded the boot loader to your ATmega328.
The reason is that your version of avrdude is not linked with libftdi and has to be compiled and linked with libftdi. You can do this by getting the source code and compiling it for your self.

Resources