Unable to compile ESP-IDF example project - esp32

I'm trying to compile my first ESP32 example project.
I set up Visual Studio Code with all the latest tools. (Python, toolschain, etc).
I'm not sure what exactly I need as I'm new in this environment, so maybe I missed something.
I followed the user guide on how to create and compile the first project, I used the Blink project from the example folder.
Here is what I get.
> Executing task: cmake -G Ninja .. <
-- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32s2
-- Checking Python dependencies...
Python requirements from C:\Users\dmitryke\esp\esp-idf\requirements.txt are satisfied.
-- Project sdkconfig file C:/ESP32_projects/blink/sdkconfig
Loading defaults file C:/ESP32_projects/blink/sdkconfig.defaults...
-- Components:
-- Component paths:
-- Configuring done
-- Generating done
-- Build files have been written to C:/ESP32_projects/blink/build
The terminal will be reused by tasks, press any key to close it.
> Executing task: cmake --build . <
[1/1] Linking C executable blink.elf
FAILED: blink.elf
cmd.exe /C "cd . && C:\Users\dmitryke\.espressif\tools\xtensa-esp32s2-elf\esp-2020r3-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-gcc.exe -mlongcalls CMakeFiles/blink.elf.dir/project_elf_src.c.obj -o blink.elf -Wl,--cref -Wl,--Map=C:/ESP32_projects/blink/build/blink.map -fno-rtti -fno-lto && cd ."
c:/users/dmitryke/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: c:/users/dmitryke/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/lib/no-rtti/crt0.o:(.literal+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command cmake --build ." terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
I removed everything from the blink.c to avoid code errors.
blink.c
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
/* Can use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
or you can edit the following line and set a number here.
*/
#define BLINK_GPIO 0x01
void app_main(void)
{
while(1) { }
}
Another issue, there is an option to run idf.py menuconfig.
Sometimes it works and sometimes it says:
C:\ESP32_projects\blink>idf.py menuconfig
'idf.py' is not recognized as an internal or external command,
operable program or batch file.
Any help will be appreciated!

All ESP IDF tasks (cmake, idf.py, etc) must be run inside a prepared environment. I would start by losing the VSC (because it's just another potential failure point) and using the basic ESP IDF command prompt. Try running idf.py menuconfig, idf.py build and idf.py -p COMx flash for configuring, building and flashing your test project.
Once you've verified that the ESP IDF environment and your project works, go back to VSC and see what's wrong there.
As a working example, this is how I compile the same sample project on my machine (Linux, ESP IDF v4.2.1) from scratch:
$ cp -r ~/esp-idf/examples/get-started/blink/ .
$ cd blink
$ idf.py build
Running cmake in directory /home/tarmo/tmp/espidftest/blink/build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -DCCACHE_ENABLE=0 /home/tarmo/tmp/espidftest/blink"...
-- Found Git: /usr/bin/git (found version "2.30.2")
-- IDF_TARGET not set, using default target: esp32
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
[SNIP]
esptool.py v3.0
Generated /home/tarmo/tmp/espidftest/blink/build/bootloader/bootloader.bin
[934/934] Generating binary image from built executable
esptool.py v3.0
Generated /home/tarmo/tmp/espidftest/blink/build/blink.bin
Project build complete. To flash, run this command:
/home/tarmo/espressif/python_env/idf4.2_py3.9_env/bin/python ../esp-idf/components/esptool_py/esptool/esptool.py -p (PORT) -b 921600 --before default_reset
--after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/blink.bin
or run 'idf.py -p (PORT) flash'
$ ls -lha
drwxr-xr-x 8 tarmo tarmo 4,0K juuni 4 12:26 build
-rw-r--r-- 1 tarmo tarmo 234 juuni 4 12:25 CMakeLists.txt
-rw-r--r-- 1 tarmo tarmo 1,5K juuni 4 12:25 example_test.py
drwxr-xr-x 3 tarmo tarmo 4,0K juuni 4 12:26 main
-rw-r--r-- 1 tarmo tarmo 177 juuni 4 12:25 Makefile
-rw-r--r-- 1 tarmo tarmo 157 juuni 4 12:25 README.md
-rw-r--r-- 1 tarmo tarmo 33K juuni 4 12:25 sdkconfig
-rw-r--r-- 1 tarmo tarmo 3 juuni 4 12:25 sdkconfig.defaults

The command window is less concerning, i got it working.
My main problem is main not being linked.

I had the same problem with building the ESP-project in VS Code, but found a solution: The project needs to be created in a folder with a different name than the example name.
I tried the blink project and it works when creating it in c:\esp-idf\ rather than in c:\esp-idf\blink. The latter will make a folder named blink within the blink folder.

You can add this code to your main(), checking your esp-idf environment first:
gpio_reset_pin(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while(1) {
printf("Turning off the LED\n");
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Turning on the LED\n");
gpio_set_level(BLINK_GPIO, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
Don't forget to close the previous terminal and open it again.

Related

Gentoo No rule to make target 'olddefconfig'

I have been following this guide from the gentto wiki to install Gentoo. I have hit a bit of a roadblock though which looks reasonably simple but I am having trouble figuring it out.
On this page: https://wiki.gentoo.org/wiki/Sakaki%27s_EFI_Install_Guide/Configuring_Secure_Boot#test_secure_boot
In the Testing Secure Boot with a Signed Kernel section whilst executing the buildkernel command I get the following error:
* Updating old config using make olddefconfig
make: *** No rule to make target 'olddefconfig'. Stop.
* buildkernel: Error: Caught signal - exiting
I don't seem to have an olddefconfig at all and even if I did have one I am not entirely sure what rule should be added to the make file.
I have read the man page for the buildkernel command and gone over this description here but sadly I have still not managed to fix the issue.
Does anyone know how to rectify this error?
So I now have an answer for this. It sometimes happens when the kernel sources have been updated to a new version, but the symbolic link /usr/src/linux hasn't been updated to
match. Gentoo leaves a partially populated kernel source tree in
/usr/src/linux--genoo even when an old kernel source version is
unmerged, and if the symbolic link /usr/src/linux still points to this.
if you run:
eselect kernel list
and it produces something like:
Available kernel symlink targets:
[1] linux-4.14.63-gentoo-r1
and
ls -l /usr/src/
produces something along the lines of:
total 8
lrwxrwxrwx 1 root root 20 Aug 18 00:33 linux -> linux-4.14.61-gentoo
drwxr-xr-x 23 root root 4096 Aug 18 02:38 linux-4.14.61-gentoo
drwxr-xr-x 25 root root 4096 Aug 18 02:33 linux-4.14.63-gentoo-r1
Running the following command will update the symbolic link and let you get on with things.
eselect kernel set 1
I emailed the author of the guide to get this information so credit goes to her. I am leaving this here in case anyone else runs into this problem in future.

Apktools on Mac

I went downloaded the Apktools from the website and got 2 files: Apktool.txt and Apktool_2.2.2. I renamed the Apktool_2.2.2 to Apktools.jar per the instructions. I then went to terminal and this was what I did:
Last login: Fri Mar 17 12:08:55 on ttys000
Roberts-MBP:~ Robert$ cd documents
Roberts-MBP:documents Robert$ cd metronomeapp/apktool
Roberts-MBP:apktool Robert$ **java -jar apktool.jar**
Apktool v2.2.2 - a tool for reengineering Android apk files
with smali v2.1.3 and baksmali v2.1.3
Copyright 2014 Ryszard Wiśniewski <brut.alll#gmail.com>
Updated by Connor Tumbleson <connor.tumbleson#gmail.com>
usage: apktool
-advance,--advanced prints advance information.
-version,--version prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
-p,--frame-path <dir> Stores framework files into <dir>.
-t,--tag <tag> Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
-f,--force Force delete destination directory.
-o,--output <dir> The name of folder that gets written. Default is apk.out
-p,--frame-path <dir> Uses framework files located in <dir>.
-r,--no-res Do not decode resources.
-s,--no-src Do not decode sources.
-t,--frame-tag <tag> Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
-f,--force-all Skip changes detection and build all files.
-o,--output <dir> The name of apk that gets written. Default is dist/name.apk
-p,--frame-path <dir> Uses framework files located in <dir>.
For additional info, see: http://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali
Roberts-MBP:apktool Robert$ **./apktool d metronome.apk**
-bash: ./apktool: No such file or directory
Roberts-MBP:apktool Robert$ **apktool d metronome.apk**
-bash: apktool: command not found
Roberts-MBP:apktool Robert$
You can see in the bold what I entered. On the 2nd and 3rd bold statements, I did it both ways because I found info that one of them works on windows and one on mac and since the mac one didn't work I wanted to try the windows one to see what it would say. Both the files are in the same directory with the apk file (metronome.apk) Does anyone know why this isn't working and what I can do to resolve it?
Thanks.
Robert
Try java -jar apktool.jar d metronome.apk
To elaborate, apktool.jar is not a command itself. It's a java Jar file that can be executed by the Java runtime.

Maven error: Could not find or load main class .usr.share.maven.boot.plexus-classworlds-2.x.jar

I have recently upgraded my Ubuntu from 14.04 to 16.04 and started getting the following error when running any mvn commands (version 3.3.9): Error: Could not find or load main class .usr.share.maven.boot.plexus-classworlds-2.x.jar. My environment variables are declared as follows:
$JAVA_HOME: /usr/lib/jvm/java-8-oracle
$PATH: /usr/local/texlive/2015/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$M2_HOME: /usr/share/maven
$M2: /usr/share/maven/bin
When trying to find a solution, I've tried removing the M2 and M2_HOME variables as suggested on various threads, which resulted in getting a different error: Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher. I have also tried running apt-get remove --purge maven and installing it again as well as downloading the .tar.gz archive, but in both cases, nothing has changed.
When looking into the /usr/share/maven/boot folder, there is a chain of symlinks pointing from plexus-classworlds-2.x.jar -> /usr/share/java/plexus-classworlds2-2.5.2.jar. Am I missing some dependencies? Or are there any old configuration files that did not get removed by --purge?
EDIT: When I execute mvn as root, I get the Launcher error instead of plexus-classworlds-2.x. Also, I have completely removed and reinstalled all plexus libraries, yet with no change.
Check if /usr/share/maven/boot has multiple jars with pattern /usr/share/maven/boot/plexus-classworlds-*.jar.
Mine was something like:
drwxr-xr-x 2 root root 4096 Dec 23 14:21 ./
drwxr-xr-x 6 root root 4096 Nov 14 2015 ../
-rw-r--r-- 1 root root 52684 Dec 12 2015 plexus-classworlds-2.5.2.jar
lrwxrwxrwx 1 root root 34 Dec 10 2015 plexus-classworlds-2.x.jar -> ../../java/plexus-classworlds2.jar
This messes up /usr/share/maven/bin/mvn bash script and executes a wrong java command.
I had to remove the jar and leave only the symbolic link.

Build failed of downloaded .mcp file in MPLAB for PIC18F2550 and PIC18F4550

I have installed Mplab version 8.9, I have downloaded a firmware package from this link
But, when I hit build all it shows me the following output and build fails:
----------------------------------------------------------------------
Debug build of project `D:\microchip\WFF Generic HID Demo 3\WFF_GenericHID_Demo_3.mcp' started.
Language tool versions: mplink.exe v9.80, mcc18.exe v9.80, mplib.exe v9.80
Preprocessor symbol `__DEBUG' is defined.
Thu May 29 15:44:49 2014
----------------------------------------------------------------------
Make: The target "D:\microchip\WFF Generic HID Demo 3\main.o" is out of date.
Executing: "C:\Program Files (x86)\Microchip\xc8\v1.31\bin\mcc18.exe" -p=18F4550 /i"..\Microchip Solutions v2011-07-14\Microchip\Include" "main.c" -fo="main.o" -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Make: The target "D:\microchip\WFF Generic HID Demo 3\usb_descriptors.o" is out of date.
Executing: "C:\Program Files (x86)\Microchip\xc8\v1.31\bin\mcc18.exe" -p=18F4550 /i"..\Microchip Solutions v2011-07-14\Microchip\Include" "usb_descriptors.c" -fo="usb_descriptors.o" -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
usb_descriptors.c:
125: rom struct{BYTE report[28];}hid_rpt01={
(984) type redeclared ^
^ (1098) conflicting declarations for variable "hid_rpt01" (usb_descriptors.c:125)
(908) exit status = 1
(908) exit status = 1
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `D:\microchip\WFF Generic HID Demo 3\WFF_GenericHID_Demo_3.mcp' failed.
Language tool versions: mplink.exe v9.80, mcc18.exe v9.80, mplib.exe v9.80
Preprocessor symbol `__DEBUG' is defined.
Thu May 29 15:44:51 2014
----------------------------------------------------------------------
BUILD FAILED
I tried to find the problem in this link also, but i could not find its root cause.
I started to try this because i wanted to make my own shields and pcb for my projects instead of arduino and the like.
Please help me with this problem.

Complete Example Yaml program on http://code.google.com/p/yaml-cpp/wiki/HowToParseADocument does not compile

Using G++ 4.6.2 on Linux
Library was built according to instructions. run_tests in test directory works fine.
setenv YAML_HOME /nfs/site/proj/dt/ltt_test_15/work_area/ironchef/new_version/ironchef/trunk/yaml/yaml-cpp-0.5.0
ls $YAML_HOME
total 640
16 CMakeCache.txt 0 build/ 0 libyaml-cpp.so.0.5# 8 test/
8 CMakeFiles/ 8 cmake_install.cmake 480 libyaml-cpp.so.0.5.0* 8 util/
16 CMakeLists.txt 0 include/ 8 license.txt 8 yaml-cpp.pc
8 CTestTestfile.cmake 8 install.txt 8 matt_sandbox/ 8 yaml-cpp.pc.cmake
40 Makefile 0 libyaml-cpp.so# 8 src/
cd matt_sandbox
g++ -o test_yaml -g -I/usr/intel/pkgs/boost/1.48.0-gcc-4.6.2/include -I$YAML_HOME/include -I$YAML_HOME/include/yaml-cpp -I$YAML_HOME/include/yaml-cpp/node -I$YAML_HOME/include/yaml-cpp/node/detail -I$YAML_HOME/include/yaml-cpp/contrib main.cpp
Compiler errors:
main.cpp: In function `void operator>>(const YAML::Node&, Vec3&)':
main.cpp:25: error: no match for 'operator>>' in 'YAML::Node::operator[](const Key&) const [with
... similar errors ....
main.cpp:51: error: 'class YAML::Parser' has no member named 'GetNextDocument'
Copy-and-paste code from complete example on http://code.google.com/p/yaml-cpp/wiki/HowToParseADocument
That example uses the old API (version 0.3.0), but you're using the new API (version 0.5.0). I've updated the main page to make that clear.
For examples using the new API, see http://code.google.com/p/yaml-cpp/wiki/Tutorial.

Resources