SmingHub / SmingRTOS

46 stars 36 forks source link

Problem compiling an example (Basic_Serial) on Linux (x86_64) #139

Open K4rolis opened 8 years ago

K4rolis commented 8 years ago

Hi,

Before reading further, please keep in mind that I'm really new at this.

What is the correct procedure (starting from scratch) to compile a sample application? Let's say I'm interested in the Basic_Serial.

Steps that I have followed:

export ESP_HOME="/home/kom/esp/esp-open-sdk/"
export SDK_BASE="/home/kom/esp/ESP8266_RTOS_SDK/"
export SMING_HOME="/home/kom/esp/SmingRTOS/sming/"
C+ app/application.cpp
AR out/build/app_app.a
LD out/build/app.out
/home/kom/esp/ESP8266_RTOS_SDK//lib/libmain.a(app_main.o): In function `user_init_task':
(.irom0.text+0x580): undefined reference to `user_rf_cal_sector_set'
/home/kom/esp/ESP8266_RTOS_SDK//lib/libmain.a(app_main.o): In function `flash_data_check':
(.irom0.text+0x655): undefined reference to `user_rf_cal_sector_set'
collect2: error: ld returned 1 exit status
/home/kom/esp/SmingRTOS/sming//Makefile-project.mk:287: recipe for target 'out/build/app.out' failed
make: *** [out/build/app.out] Error 1

What did I miss? Am I using incorrect RTOS SDK version? Adding code from here to user_main.cpp seems to fix the build issue, is this the correct way of solving this? If so, why hasn't this been submitted to the repo?

My apologies if the formatting is less-than-ideal - this is my first message on GitHub ever!

Karolis

zhivko commented 8 years ago

Today I tried compiling Basic_rBoot sample and I also get this error:

~/git/SmingRtosOff/samples/Basic_rBoot$ make rebuild
OC out/build/libmain2.a
make -C /home/klemen/git/SmingRtosOff/sming/rboot
make[1]: Entering directory '/home/klemen/git/SmingRtosOff/sming/rboot'
CC rboot-stage2a.c
LD /home/klemen/git/SmingRtosOff/samples/Basic_rBoot/out/build/rboot-stage2a.elf
E2 /home/klemen/git/SmingRtosOff/samples/Basic_rBoot/out/build/rboot-hex2a.h
CC rboot.c
LD /home/klemen/git/SmingRtosOff/samples/Basic_rBoot/out/build/rboot.elf
E2 /home/klemen/git/SmingRtosOff/samples/Basic_rBoot/out/firmware/rboot.bin
make[1]: Leaving directory '/home/klemen/git/SmingRtosOff/sming/rboot'
C+ app/application.cpp
CC /home/klemen/git/SmingRtosOff/sming/rboot/appcode/rboot-bigflash.c
CC /home/klemen/git/SmingRtosOff/sming/rboot/appcode/rboot-api.c
AR out/build/app_app.a
LD out/build/app_0.out
out/build/libmain2.a(app_main.o): In function `user_init_task':
(.irom0.text+0x580): undefined reference to `user_rf_cal_sector_set'
out/build/libmain2.a(app_main.o): In function `flash_data_check':
(.irom0.text+0x655): undefined reference to `user_rf_cal_sector_set'
collect2: error: ld returned 1 exit status
/home/klemen/git/SmingRtosOff/sming/Makefile-rboot.mk:334: recipe for target 'out/build/app_0.out' failed
make: *** [out/build/app_0.out] Error 1

This is very strange sinc eI know I compiled this succesfully before.

zhivko commented 8 years ago

For me I needed to change main.cpp to this:

#include "espressif/esp_common.h"

#include "sming/include/sming_config.h"

//#include "sming/include/SmingCore.h"

extern void init();

extern "C" void  __attribute__((weak)) user_init(void)
{
    printf("Sming RTOS Proof of Concept \r\n");
    printf("SDK version:%s\n", system_get_sdk_version());
    printf("FreeHeapSize = %d\r\n",xPortGetFreeHeapSize());
    init();
}

extern "C" uint32 ICACHE_FLASH_ATTR
user_rf_cal_sector_set(void)
{
    //enum
    flash_size_map size_map = system_get_flash_size_map();
    uint32 rf_cal_sec = 0;

    switch (size_map) {
        case FLASH_SIZE_4M_MAP_256_256:
            rf_cal_sec = 128 - 5;
            break;

        case FLASH_SIZE_8M_MAP_512_512:
            rf_cal_sec = 256 - 5;
            break;

        case FLASH_SIZE_16M_MAP_512_512:
        case FLASH_SIZE_16M_MAP_1024_1024:
            rf_cal_sec = 512 - 5;
            break;

        case FLASH_SIZE_32M_MAP_512_512:
        case FLASH_SIZE_32M_MAP_1024_1024:
            rf_cal_sec = 1024 - 5;
            break;

        default:
            rf_cal_sec = 0;
            break;
    }

    return rf_cal_sec;
}

// For compatibility with SDK v1.1
extern "C" void __attribute__((weak)) user_rf_pre_init(void)
{
    // RTC startup fix, author pvvx
    volatile uint32 * ptr_reg_rtc_ram = (volatile uint32 *)0x60001000;
    if((ptr_reg_rtc_ram[24] >> 16) > 4) {
        ptr_reg_rtc_ram[24] &= 0xFFFF;
        ptr_reg_rtc_ram[30] &= 0;
    }
}

notice: extern "C" uint32 ICACHE_FLASH_ATTR instead of uint32 ICACHE_FLASH_ATTR as it is mentioned in @K4rolis post above.

hreintke commented 8 years ago

@zhivko : If you create a PR I will merge

K4rolis commented 8 years ago

@hreintke what about the errno.h thing? Or am I doing something wrong? And also, was the method I used the correct method to fetch the required RTOS SDK?

zhivko commented 8 years ago

@hreintke ok will do that, but how Basic_rBoot sample works for you with upper error - sorry maybe missing a point here.

zhivko commented 8 years ago

@hreintke it will be hard for me to create pull request since my SmingRTOS includes some additional features. But here is diff.

user_rf_cal_sector_set.txt