Forum: Mikrocontroller und Digitale Elektronik Projekt für nodeMCU compilieren. make


von Jonas (Gast)


Lesenswert?

Hallo,
ich habe immer noch Probleme ein Projekt für einen NodeMCU zu bauen.
Ich bin hiernach vorgegangen
https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/
unter C:\msys32\opt liegt xtensa-lx106-elf
unter C:\msys32\home\esp liegt ESP8266_RTOS_SDK und esp-idf

Das Projekt hello-world habe ich mir nach H:\projects\esp kopiert.
Wie in der Anleitung, konnte ich es hier compilieren und flashen.

Jetzt wollte ich ein eigenes Projekt anlegen und das lässt sich nicht 
mehr bauen. Ich weiß auch nicht mehr woran es noch liegen könnte.

Ich habe einen Ordner
connect_router
in diesem Ordner ist
CMakeLists.txt
1
# The following lines of boilerplate have to be in your project's
2
# CMakeLists in this exact order for cmake to work correctly
3
cmake_minimum_required(VERSION 3.5)
4
5
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6
project(connect-router)
Makefile
1
#
2
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
3
# project subdirectory.
4
#
5
6
PROJECT_NAME := connect-router
7
8
include $(IDF_PATH)/make/project.mk

eine erstellte sdkonfig

Sowie ein Ordner "main"
Dieser Ordner enthält
component.mk
1
#
2
# "main" pseudo-component makefile.
3
#
4
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
5
#

sowie
connect_router.c (Diese gibt es nur einmal. Habe sie aber für zwei 
verschiedene Möglichkeiten angepasst)
ohne rtos:
1
#include <stdio.h>
2
#include <stdint.h>
3
//#include "esp_log.h"
4
//#include "esp_idf_version.h"
5
6
7
//void __attribute__((weak)) app_main(void)
8
int main(void)
9
{
10
  //ESP_LOGI(TAG, "SDK factory test firmware version:%s\n", esp_get_idf_version());
11
  while(1)
12
  {
13
    printf("print\r\n");
14
    for(uint8_t x=0; x<=100; x++)
15
    { 
16
      volatile uint8_t y = 0;
17
    }
18
  }
19
20
  return 1;
21
}
mit RTOS
1
#include <stdio.h>
2
#include <stdint.h>
3
//#include "esp_log.h"
4
//#include "esp_idf_version.h"
5
6
7
void __attribute__((weak)) app_main(void)
8
{
9
  //ESP_LOGI(TAG, "SDK factory test firmware version:%s\n", esp_get_idf_version());
10
  while(1)
11
  {
12
    printf("print\r\n");
13
    for(uint8_t x=0; x<=100; x++)
14
    { 
15
      volatile uint8_t y = 0;
16
    }
17
  }
18
}

Die ganzen files (bis auf connect_router.c) sind aus dem beispielprojekt 
hello-world kopiert und mit dem neuen namen angepasst.

Wenn ich das Projekt connect_router.c ohne rtos bauen möchte (habe es im 
menuconfig dekatirviert)
bekomme ich von make die rückgabe
1
C:/msys32/home/esp/ESP8266_RTOS_SDK/components/newlib/newlib/port/locks.c:170: undefined reference to `xTaskGetSchedulerState'
2
C:/msys32/home/esp/ESP8266_RTOS_SDK/components/newlib/newlib/port/locks.c:170: undefined reference to `xQueueCreateMutex'
3
... ... ...
Das sind fehler, die wegen rtos sind. Aber das möchte ich ja auch gar 
nciht haben.
Wenn ich es wieder aktiviere und connect_router.c bauen möchte,
bekomme ich den Fehler
1
H:/Projects/ESP/connect_Router/build/esp8266\libesp8266.a(startup.o):(.literal.user_init_entry+0x1c): undefined reference to `app_main'
2
H:/Projects/ESP/connect_Router/build/esp8266\libesp8266.a(startup.o): In function `user_init_entry':
3
C:/msys32/home/esp/ESP8266_RTOS_SDK/components/esp8266/source/startup.c:87: undefined reference to `app_main'
4
collect2.exe: error: ld returned 1 exit status
5
make: *** [C:/msys32/home/esp/ESP8266_RTOS_SDK/make/project.mk:510: /h/Projects/ESP/connect_Router/build/connect-router.elf] Error 1

Warum findet der meine app_main hier nicht? Und im BeipsielCode schon?
Wie kann ich ein Projekt ohne rtos erstellen?

von Achim M. (minifloat)


Lesenswert?

Hast du auch fein clean vor dem Rebuild gemacht?
Gibt es einen Header, wo "int main(void)" bzw. app_main() jeweils 
definiert sein müssen?

von Jonas (Gast)


Lesenswert?

Achim M. schrieb:
> Hast du auch fein clean vor dem Rebuild gemacht?

Das habe ich gemacht
also
make clean

Achim M. schrieb:
> Gibt es einen Header, wo "int main(void)" bzw. app_main() jeweils
> definiert sein müssen?
Wo sollte diese denn sein? In den Beispielprojekten ist auch nirgendwo 
eine header.

z.B. im main Ordner vom Beispiel hello world ist nur
CMakeLists.txt
1
idf_component_register(SRCS "hello_world_main.c"
2
                    INCLUDE_DIRS "")
(diese habe ich bei mir im ordner auch kopiert und den Namen angepasst. 
Problem ist aber das selbe

component.mk
1
#
2
# "main" pseudo-component makefile.
3
#
4
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
hier ist auch alles auskommentiert

hello_world_main.c
1
/* Hello World Example
2
3
   This example code is in the Public Domain (or CC0 licensed, at your option.)
4
5
   Unless required by applicable law or agreed to in writing, this
6
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7
   CONDITIONS OF ANY KIND, either express or implied.
8
*/
9
#include <stdio.h>
10
#include "freertos/FreeRTOS.h"
11
#include "freertos/task.h"
12
#include "esp_system.h"
13
#include "esp_spi_flash.h"
14
15
16
void app_main()
17
{
18
    printf("Hello world!\n");
19
20
    /* Print chip information */
21
    esp_chip_info_t chip_info;
22
    esp_chip_info(&chip_info);
23
    printf("This is ESP8266 chip with %d CPU cores, WiFi, ",
24
            chip_info.cores);
25
26
    printf("silicon revision %d, ", chip_info.revision);
27
28
    printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
29
            (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
30
31
    for (int i = 10; i >= 0; i--) {
32
        printf("Restarting in %d seconds...\n", i);
33
        vTaskDelay(1000 / portTICK_PERIOD_MS);
34
    }
35
    printf("Restarting now.\n");
36
    fflush(stdout);
37
    esp_restart();
38
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.