About the math include
Closed this issue · 36 comments
when I include math.h and use cos() function, the compiling will pass.
but when run the app at opencpu(BC26), it always crashed and reboot.
I'm not sure if need add some gcc path of include into c_cpp_properties.json
the output of debug:
F1: 0000 0000
V0: 0000 0000 [0001]
00: 0006 000C
01: 0000 0000
U0: 0000 0001 [0000]
T0: 0000 00B4
Leaving the BROMRDY
+CFUN: 1
------------- Exception called -------------
genie connected: Yesauto-reboot: Yes
F1: 0000 0000
V0: 0000 0000 [0001]
00: 0006 000C
01: 0000 0000
U0: 0000 0001 [0000]
T0: 0000 00B4
Leaving the BROMRDY
+CFUN: 1
------------- Exception called -------------
genie connected: Yesauto-reboot: Yes
//the codes:
void proc_main_task(s32 taskId)
{
s32 ret;
u32 cnt = 0;
double a = 0;
double b = 0;
char Buff[10]="0.345";
char* pStr;
// Register & open UART port
ret = Ql_UART_Register(m_myUartPort, CallBack_UART_Hdlr, NULL);
if (ret < QL_RET_OK)
{
Ql_Debug_Trace("Fail to register serial port[%d], ret=%d\r\n", UART_PORT1, ret);
}
ret = Ql_UART_Open(m_myUartPort, 115200, FC_NONE);
if (ret < QL_RET_OK)
{
Ql_Debug_Trace("Fail to open serial port[%d], ret=%d\r\n", UART_PORT1, ret);
}
a = cos(b); //crashed here
huh...
for me math work BC66NBR01A04V01
#include <math.h>
Serial.printf("cos(3.14) = %f\n", cos(3.14));
result:
cos(3.14) = -0.999999
sin(3.14) = 0.001593
I not have BC26 for tests
BC66 math is:
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
Do you have BC26 latest SDK?
NO, I can not download SDK from baidu.com
#include "custom_feature_def.h"
#include "ql_type.h"
#include "ql_stdlib.h"
#include "ql_uart.h"
#include "ril.h"
#include <math.h>
void CB_UART_Hdlr(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void *customizedPara) {}
char DBG_BUFFER[512];
#define DBG(FORMAT, ...)
{
Ql_memset(DBG_BUFFER, 0, 512);
Ql_sprintf(DBG_BUFFER, FORMAT, ##VA_ARGS);
Ql_UART_Write(UART_PORT0, (u8 *)DBG_BUFFER, Ql_strlen(DBG_BUFFER));
}
void proc_main_task(s32 taskId)
{
s32 ret;
Ql_UART_Register(UART_PORT0, CB_UART_Hdlr, NULL);
Ql_UART_Open(UART_PORT0, 115200, FC_NONE);
DBG("BEGIN\n");
double a = 3.14, b;
b = cos(a);
DBG("cos(3.14) = %f\n", b);
ST_MSG msg;
while (1)
{
Ql_OS_GetMessage(&msg);
}
}
result:
F1: 0000 0000
V0: 0000 0000 [0001]
00: 0006 000C
01: 0000 0000
U0: 0000 0001 [0000]
T0: 0000 00B4
Leaving the BROM
BEGIN
cos(3.14) = -0.999999
BTW: you can test to flash your BC26 with BC66 firmware ( but first make NVDM backup )
BC66NBR01A04V01 or BC66NBR01A05V01
I do not think there are any differences...
I had upload SDK to:
https://drive.google.com/file/d/1MWJjCzdnAu1rHSiF1FXQ83ovcvXXQMoT/view
Just notied the gcc version is diff, this sdk gcc no elf file .
I had try to relpace the ori gcc with my sdk gcc(all compiling chain files), compiling ok, still crashed.
I get it but I cannot see differences in make file
I use standart GCC for M4 and work fine with M66, MC60, BC66, BG96
Try compile with Quectel SDK for cos() test
Thanks!
Would please share the BC66 SDK with me?
I had checked the harware datasheet, seems BC66 is same as BC26, only some band support is diff.
BC26 seems to be low price version of BC66 with PA downgraded.
email me: the.wizarda[AT]gmail.com
Had sent your mail,
some question: for BC26 OPENCPU : does the fota option included but no related folder and source in the git? join(CORE_DIR, "fota", "inc"),
https://cloud.comet.bg/index.php/s/mc49pbHtL7fBP5P?path=%2FBC66%20Documents
BC66 SDK has no folder fota and Quectel DFOTA packer is not ready
FOTA is just one AT command
got it , thanks!
I had checked SDK, there is a line in make file def
ENV_INC='$(strip $(GCC_INSTALL_PATH))/arm-none-eabi/include'
I dont know how to check my VScode ENV 's include path of gcc, can you show me ?
another strange thing is :
Even I comment #include <math.h> like:
//#include <math.h>
the compiling can go down without any error or warning.
Are you have other GCC platforms in PlatformIO IDE
Maybe IDE link to other compiler without libgcc for hard float
I ask PlatformIO how to set manual gcc path
there is math and gcc libs search path
https://github.com/Wiz-IO/platform-quectel/blob/master/builder/frameworks/opencpu_bc66.py#L68
Thanks!
I used ESP32 with platformIO before, I m not sure if some GCC env is mixed-up .
Another thing is I had used SDK to build APP, seems it works fine:
+CFUN: 1
OpenCPU: float test !
cos(3.14) = -0.999999
nice :) how?
is "mixed"https://github.com/Wiz-IO/platform-quectel/blob/master/platform.json#L43
The platform.json is no problem from git downloaded, and I had follow your instruction paste the git link to advanced Platform to get it.
but for the LIBS=[ "gcc", "m", "app_start" ],
https://github.com/Wiz-IO/platform-quectel/blob/master/builder/frameworks/opencpu_bc66.py#L68
I cannot tell if it include the header files of include dir
From my point, gcc exe file is no problem, (if I did not use gcc include file, the runing is no problem)
It should be header file include error path.
So I asked you where to check the enviroment's gcc include.
I think I find some clue, I used same workspace with ESP32 project, I will check the woarkspace.
example_float_math.c.txt
example_float_math.c.txt
Nothing Changed, still failed.
- I had checked the win system path , no error or ESP32 path included.
- I had check the VScode workspace's "Path" ," Include“, Nothing related with ESP32‘s Xtensa gcc.
- I had discard this workspace, generate a new project, builded, still failed, app crashed.
- I shift to pure dev on linux(no esp32 dev before), building, then windows upload, failed, app crashed.
there is the build log:(example_float_math.c include the main entry, this is example of SDK, used math.h, but building show No dependencies ,strange!!)
struggling...... any suggestion???
Verbose mode can be enabled via -v, --verbose
option
<<<<<<<<<<<< QUECTEL BC26 MODULE 2018 Georgi Angelov >>>>>>>>>>>>
CONFIGURATION: https://docs.platformio.org/page/boards/quectel/bc26.html
PLATFORM: Quectel > Quectel BC26 module
HARDWARE: ARM, MT2625 78MHz 97.66KB RAM (195.31KB Flash)
DEBUG: CURRENT(uart) ON-BOARD(uart)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs\bc26\src\example_float_math.o
Compiling .pioenvs\bc26\framework\custom_sys_cfg.o
Compiling .pioenvs\bc26\framework\ril\src\ril_atResponse.o
Compiling .pioenvs\bc26\framework\ril\src\ril_init.o
Compiling .pioenvs\bc26\framework\ril\src\ril_lwm2m.o
Compiling .pioenvs\bc26\framework\ril\src\ril_network.o
Compiling .pioenvs\bc26\framework\ril\src\ril_onenet.o
Compiling .pioenvs\bc26\framework\ril\src\ril_socket.o
Compiling .pioenvs\bc26\framework\ril\src\ril_system.o
Compiling .pioenvs\bc26\framework\ril\src\ril_urc.o
Compiling .pioenvs\bc26\framework\ril\src\ril_util.o
Compiling .pioenvs\bc26\framework\sys_config.o
Compiling .pioenvs\bc26\framework\ril\ril_atResponse.o
Compiling .pioenvs\bc26\framework\ril\ril_init.o
Compiling .pioenvs\bc26\framework\ril\ril_lwm2m.o
Archiving .pioenvs\bc26\libframework.a
Compiling .pioenvs\bc26\framework\ril\ril_network.o
Compiling .pioenvs\bc26\framework\ril\ril_onenet.o
Compiling .pioenvs\bc26\framework\ril\ril_socket.o
Compiling .pioenvs\bc26\framework\ril\ril_system.o
Compiling .pioenvs\bc26\framework\ril\ril_urc.o
Compiling .pioenvs\bc26\framework\ril\ril_util.o
Archiving .pioenvs\bc26\framework\libril.a
Linking .pioenvs\bc26\program.elf
Checking size .pioenvs\bc26\program.elf
Building .pioenvs\bc26\program.dat
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [= ] 5.4% (used 5445 bytes from 100000 bytes)
PROGRAM: [ ] 0.6% (used 1116 bytes from 200000 bytes)
open your file
https://github.com/Wiz-IO/platform-quectel/blob/master/platform.json#L43
and change to
"version": "=1.70201.0"
delete folder toolchain-gccarmnoneeabi
build
platformIO must download version 1.70201.0
Still crashed!
Changed according to your suggestion.
Then the gccarmnoneeabi download the new "version": "=1.70201.0"
the building result and size is same as before, no change, then I clean and rebuild it, Crash without any change.
I used the verbose build, the same crash and same size of DATA and Program size.
VerboseBuildLog.txt
send me the APP .bin .cfg and .elf file
Leaving the BROM
OpenCPU: float test !
and crash :)
give me c file
SDK_build_BC26.zip
The c file also included in the zip file, and all SDK build result(which can run on BC26 without crash)
:)
APP BEGIN
MATH TEST
cos(3) = -0.989992
acos(3) = nan
sin(3) = 0.141120
asin(3) = nan
sum=116.691290
atof1=116.123 atof2=0.567800 var=58.000000 sum=10.567800
atof1=116.123 atof2=0.567800 var=58.000000
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
Float test, pos=0.845889
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
dst = 9.282km
0 MSG: 4097 0 0
Ril Ready
Used main.c to compile-build: still crash.
genie connected: Yes
auto-reboot: Yes
F1: 0000 0000
V0: 0000 0000 [0001]
00: 0006 000C
01: 0000 0000
U0: 0000 0001 [0000]
T0: 0000 00B4
Leaving the BROM
RDY
+CFUN: 1
APP BEGIN
MATH TEST
------------- Exception called -------------
genie connected: Yes
auto-reboot: Yes
But if use your program.bin file, it's OK.
RDY
+CFUN: 1
APP BEGIN
MATH TEST
cos(3) = -0.989992
acos(3) = nan
sin(3) = 0.141120
asin(3) = nan
sum=116.691290
atof1=116.123 atof2=0.567800 var=58.000000 sum=10.567800
atof1=116.123 atof2=0.567800 var=58.000000
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
Float test, pos=0.845889
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
dst = 9.282km
0 MSG: 4097 0 0
Ril Ready
upload my program.bin from zip
result from your APPGS3MDM32A01
OpenCPU: float test !
cos(3.14) = -0.999999
sum=116.691290
atof1=116.123 atof2=0.567800 var=58.000000 sum=10.567800
atof1=116.123 atof2=0.567800 var=58.000000
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
Float test, pos=0.845889
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
dst = 9.282km
this is my settings
env.Append(
CPPDEFINES = [ # -D
"CORE_" + core.upper().replace("-", "_"),
platform.upper(),
],
CPPPATH = [ # -I
join(framework_dir, "opencpu", core),
join(framework_dir, "opencpu", core, "include"),
join(framework_dir, "opencpu", core, "ril", "inc"),
join("$PROJECT_DIR", "lib"),
join("$PROJECT_DIR", "include"),
join("$PROJECT_DIR", "config")
],
CFLAGS = [
"-Os", "-g", "-c",
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-mlittle-endian",
"-mthumb",
"-std=c11",
#"-fno-builtin",
"-fdata-sections",
"-ffunction-sections",
"-fno-strict-aliasing",
"-fsingle-precision-constant",
"-Wall",
"-Wextra",
"-Wno-unused",
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-Wno-pointer-sign",
#"-Wno-pointer-compare",
#"-Wno-type-limits",
#"-Wno-int-conversion",
#"-Wno-missing-braces",
#"-Wno-missing-field-initializers",
],
LINKFLAGS = [
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-mlittle-endian",
"-mthumb",
"-nostartfiles",
"-fno-use-cxa-atexit",
"-Xlinker", "--gc-sections",
"-Wl,--gc-sections",
],
LIBPATH = [ lib_dir ],
LDSCRIPT_PATH = linker,
LIBS = [ "gcc", "m", "_app_start_{}".format(core), ],
I just noticed your setting is a little big diff with opencpu_bc66.py, which like below(I used):
def bc66_init(env):
DIR = os.path.dirname(env.get("BUILD_SCRIPT"))
TOOL_DIR = env.PioPlatform().get_package_dir("tool-quectel")
CORE = env.BoardConfig().get("build.core") # "bc66"
CORE_DIR = join(env.PioPlatform().get_package_dir("framework-quectel"), "opencpu", CORE)
env.Append(
CPPDEFINES=["OPENCPU", "CORE_"+CORE.upper(), "_REENT_SMALL"], # -D
CPPPATH=[ # -I
CORE_DIR,
join(CORE_DIR, "include"),
join(CORE_DIR, "ril", "inc"),
join(CORE_DIR, "fota", "inc"),
],
CFLAGS=[
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-fsingle-precision-constant",
"-mthumb",
"-mthumb-interwork",
"-mlong-calls",
"-std=c99",
"-c", "-g", "-Os",
"-fno-builtin",
"-ffunction-sections",
"-fdata-sections",
"-fno-strict-aliasing",
"-fno-common",
"-Wall",
"-Wp,-w",
"-Wstrict-prototypes",
"-Wno-implicit-function-declaration",
],
LINKFLAGS=[
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-mthumb",
"-mthumb-interwork",
"-nostartfiles",
#"-Rbuild",
"-Wl,--gc-sections,--relax",
"-Wl,-wrap=malloc",
"-Wl,-wrap=calloc",
"-Wl,-wrap=realloc",
"-Wl,-wrap=free"
],
LIBPATH=[CORE_DIR],
LDSCRIPT_PATH=join(CORE_DIR, "linkscript.ld"),
LIBS=[ "gcc", "m", "app_start" ],
BUILDERS = dict(
ElfToBin = Builder(
action=env.VerboseAction(" ".join([
"$OBJCOPY",
"-O",
"binary",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".dat"
),
MakeHeader = Builder( # Add BIN Header
action = env.VerboseAction(bc66_header, "Adding GFH header"),
suffix = ".bin"
)
), # dict
UPLOADCMD = bc66_uploader
) # env.Append
libs = []
libs.append(
env.BuildLibrary(
join("$BUILD_DIR", "framework"),
join( CORE_DIR ),
))
libs.append(
env.BuildLibrary(
join("$BUILD_DIR", "framework", "ril"),
join(CORE_DIR, "ril", "src")
))
env.Append( LIBS = libs )
yep, I know - this is my last port settings for new version
I update git soon
include full Arduino compatible ports for BC66, M66 and MC60
Sure, wait for u update, it should be works, I just replace build argc items it in my be66.py.
It can works a little more:(I think this is root cause)
RDY
+CFUN: 1
APP BEGIN
MATH TEST
cos(3) = -0.989992
------------- Exception called -------------
genie connected: Yes
auto-reboot: Yes
BTW:still some link option failed to compile. like linker define and lib_dir define etc.
would you please share the whole python file with me?
I will check at my side.
I found the problem:
.....platformio\packages\framework-quectel\opencpu\bc66
rem this ___libgcc.a
put other -Wno- to remove of Quectel warnings...
#"-Wno-pointer-compare",
#"-Wno-type-limits",
#"-Wno-int-conversion",
#"-Wno-missing-braces",
#"-Wno-missing-field-initializers",
#"-Wno-implicit-function-declaration",
replace this ( on git is changed )
CPPDEFINES=[ "CORE_BC66", "OPENCPU"], # -D
CPPPATH=[ # -I
CORE_DIR,
join(CORE_DIR, "include"),
join(CORE_DIR, "ril", "inc"),
join(CORE_DIR, "fota", "inc"),
],
CFLAGS=[
"-Os", "-g", "-c",
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-mlittle-endian",
"-mthumb",
"-std=c11",
"-fdata-sections",
"-ffunction-sections",
"-fno-strict-aliasing",
"-fsingle-precision-constant",
"-Wall",
"-Wextra",
"-Wno-unused",
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-Wno-pointer-sign",
],
LINKFLAGS=[
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-mlittle-endian",
"-mthumb",
"-nostartfiles",
"-Xlinker", "--gc-sections",
"-Wl,--gc-sections",
],
LIBPATH=[CORE_DIR],
LDSCRIPT_PATH=join(CORE_DIR, "linkscript.ld"),
LIBS=[ "gcc", "m", "app_start" ],
Math test work and with Arduino and OpenCPU
arduino_math_test.zip
I dont understand waht's mean of rem ___libgcc.a
I had tried rename it, build , seems succ.
Would you please give some explaination of libgcc.a ? why it cause such a issue?
RDY
+CFUN: 1
OpenCPU: float test !
sum=116.691290
atof1=116.123 atof2=0.567800 var=58.000000 sum=10.567800
atof1=116.123 atof2=0.567800 var=58.000000
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
Float test, pos=0.845889
Float test, a=0.85,b=0.15,radLat1=31.110,radLat2=121.290, s=9.00000
dst = 9.282km
remark, rename or delete...
This lib is from original SDK, but apparently does not work with this compiler