漫漫朔雪
漫漫朔雪
This guy hasn't written anything yet

注册于 3 years ago

回答
0
文章
0
关注者
0

    本帖最后由 aozima 于 2018-8-27 09:26 编辑


rtconfig.h内容如下:
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__


/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread Configuration */

/* RT-Thread Kernel */

#define RT_NAME_MAX 8
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 100
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_IDEL_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_DEBUG

/* Inter-Thread communication */

#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE

/* Memory Management */

#define RT_USING_MEMPOOL
#define RT_USING_MEMHEAP
#define RT_USING_SLAB
#define RT_USING_HEAP

/* Kernel Device Object */

#define RT_USING_DEVICE
#define RT_USING_INTERRUPT_INFO
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart"
#define RT_USING_MODULE

/* RT-Thread Components */

#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10

/* C++ features */

#define RT_USING_CPLUSPLUS

/* Command shell */

#define RT_USING_FINSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_ARG_MAX 10

/* Device virtual file system */

#define RT_USING_DFS
#define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 2
#define DFS_FILESYSTEM_TYPES_MAX 2
#define DFS_FD_MAX 16
#define RT_USING_DFS_ELMFAT

/* elm-chan's FatFs, Generic FAT Filesystem Module */

#define RT_DFS_ELM_CODE_PAGE 936
#define RT_DFS_ELM_WORD_ACCESS
#define RT_DFS_ELM_USE_LFN_3
#define RT_DFS_ELM_USE_LFN 3
#define RT_DFS_ELM_MAX_LFN 255
#define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
#define RT_DFS_ELM_REENTRANT
#define RT_USING_DFS_DEVFS
#define RT_USING_DFS_ROMFS
#define RT_USING_DFS_RAMFS
#define RT_USING_DFS_UFFS
#define RT_UFFS_ECC_MODE_3
#define RT_UFFS_ECC_MODE 3

/* Device Drivers */

#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_USING_CAN
#define RT_CAN_USING_HDR
#define RT_USING_HWTIMER
#define RT_USING_CPUTIME
#define RT_USING_PIN
#define RT_USING_MTD_NAND

/* Using USB */

#define RT_USING_USB_HOST
#define RT_USBH_MSTORAGE
#define UDISK_MOUNTPOINT "/"
#define RT_USING_USB_DEVICE
#define RT_USBD_THREAD_STACK_SZ 4096
#define USB_VENDOR_ID 0x0FFE
#define USB_PRODUCT_ID 0x0001
#define RT_USB_DEVICE_COMPOSITE
#define RT_USB_DEVICE_CDC
#define RT_USB_DEVICE_NONE
#define RT_USB_DEVICE_MSTORAGE
#define RT_USB_DEVICE_HID
#define RT_USB_DEVICE_RNDIS
#define RT_USB_DEVICE_ECM
#define RT_USB_DEVICE_WINUSB
#define RT_WINUSB_GUID "{6860DC3C-C05F-4807-8807-1CA861CC1D66}"
#define RT_USB_MSTORAGE_DISK_NAME "flash0"
#define RT_USB_DEVICE_HID_KEYBOARD
#define RT_USB_DEVICE_HID_KEYBOARD_NUMBER 1
#define RT_USB_DEVICE_HID_MOUSE
#define RT_USB_DEVICE_HID_GENERAL
#define RT_USB_DEVICE_HID_GENERAL_OUT_REPORT_LENGTH 63
#define RT_USB_DEVICE_HID_GENERAL_IN_REPORT_LENGTH 63
#define RT_USB_DEVICE_HID_MEDIA

/* POSIX layer and C standard library */

#define RT_USING_LIBC
#define RT_USING_POSIX

/* Network */

/* Socket abstraction layer */

#define RT_USING_SAL

/* protocol stack implement */

#define SAL_USING_LWIP
#define SAL_USING_POSIX
#define SAL_PROTO_FAMILIES_NUM 4

/* light weight TCP/IP stack */

#define RT_USING_LWIP
#define RT_USING_LWIP202
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
#define RT_LWIP_DHCP
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1

/* Static IPv4 Address */

#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
#define RT_LWIP_UDP
#define RT_LWIP_TCP
#define RT_MEMP_NUM_NETCONN 8
#define RT_LWIP_PBUF_NUM 16
#define RT_LWIP_RAW_PCB_NUM 4
#define RT_LWIP_UDP_PCB_NUM 4
#define RT_LWIP_TCP_PCB_NUM 4
#define RT_LWIP_TCP_SEG_NUM 40
#define RT_LWIP_TCP_SND_BUF 8196
#define RT_LWIP_TCP_WND 8196
#define RT_LWIP_TCPTHREAD_PRIORITY 10
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_PRIORITY 12
#define RT_LWIP_ETHTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
#define LWIP_NETIF_STATUS_CALLBACK 1
#define SO_REUSE 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_NETIF_LOOPBACK 0

/* Modbus master and slave stack */


/* AT commands */


/* VBUS(Virtual Software BUS) */


/* Utilities */


/* RT-Thread online packages */

/* IoT - internet of things */


/* Wi-Fi */

/* Marvell WiFi */


/* Wiced WiFi */


/* security packages */


/* language packages */


/* multimedia packages */


/* tools packages */


/* system packages */

#define PKG_USING_GUIENGINE
#define PKG_USING_GUIENGINE_V200
#define GUIENGINE_NAME_MAX 16
#define GUIENGINE_USING_TTF
#define GUIENGINE_TTF_UTF8
#define GUIENG_USING_FNT_FILE
#define GUIENGINE_USING_FONT16
#define GUIENGINE_USING_FONT12
#define GUIENGINE_USING_FONTHZ
#define GUIENGINE_USING_HZ_FILE
#define GUIENGINE_IMAGE_XPM
#define GUIENGINE_USING_JPG
#define GUIENGINE_IMAGE_TJPGD
#define GUIENGINE_USING_PNG
#define GUIENGINE_IMAGE_LODEPNG
#define GUIENGINE_IMAGE_BMP
#define GUIENGINE_IMAGE_CONTAINER
#define GUIENGINE_USING_DEMO

/* peripheral libraries and drivers */


/* miscellaneous packages */


/* sample package */


/* example package: hello */

#define RT_USING_UART1

#endif

主线(master, 2018-08-13下载),bsp\beaglebone,出问题位置:src\slab.c的rt_page_alloc函数,以下行:
/* lock heap */
rt_sem_take(&heap_sem, RT_WAITING_FOREVER);

这里heap_sem尚未初始化,导致rt_sem_take函数以下行出现断言失败:
RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);

修改了rtconfig.py文件,但是SConstruct还不知道怎么更改.
SConstruct内容如下:
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *

TARGET = 'rtthread-beaglebone.' + rtconfig.TARGET_EXT

env = Environment(tools = ['mingw'], // 这个地方显然需要修改
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
CXX = rtconfig.CC, CXXFLAGS = rtconfig.CXXFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)

Export('RTT_ROOT')
Export('rtconfig')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT)

# make a building
DoBuilding(TARGET, objs)

怎么修改env配置呢?我在setting-->startup-->enviroment中增加环境变量,但是仍然不起作用

@yqiu MDK中的armclang编译器.
RTT_EXEC_PATH和RTT_CC我有点疑惑,如果我未在系统变量中设置的话,进入env环境,执行set的话,会看到以下设置
RTT_CC=gcc
RTT_EXEC_PATH=D:\work\env\tools\ConEmu\ConEmu\..\..\..\tools\gnu_gcc\arm_gcc\mingw\bin
然后我在用户变量中更改了这两个变量,并重启计算机,进入env环境后,发现这两个变量并没有变化.

@tanek libc我使用libc\compilers\armlibc

谢谢bernard大侠!找到了

DefineGroup(name, src, depend, **parameters)
这是RT-Thread基于SCons扩展的一个方法(函数)。 DefineGroup用于定义一个组件。组件可以是一个目录(下的文件或子目录),也是后续一些IDE工程文件中的一个Group或文件夹。
name来定义这个group的名字
src用于定义这个Group中包含的文件,一般指的是C/C++源文件。方便起见,也能够通过Glob函数采用通配符的方式列出SConscript文件所在目录中匹配的文件。
depend 用于定义这个Group编译时所依赖的选项(例如finsh组件依赖于RT_USING_FINSH宏定义)。编译选项一般指rtconfig.h中定义的RT_USING_xxx宏。当在rtconfig.h配置文件中定义了相应宏时,那么这个Group才会被加入到编译环境中进行编译。如果依赖的宏并没在rtconfig.h中被定义,那么这个Group将不会被加入编译。相类似的,在使用scons生成为IDE工程文件时,如果依赖的宏未被定义,相应的Group也不会在工程文件中出现。
parameters则可以输入一组字符串,后面还可以加入的参数包括:
CCFLAGS – C源文件编译参数;
CPPPATH – 头文件路径;
CPPDEFINES – 添加预定义宏;
LINKFLAGS – 链接时参数。
LIBRARY – 包含此参数,则会将组件生成的目标文件打包成库文件
可见DefineGroup的功能十分强大,实际使用时不需要配置所有参数。

建议menuconfig后,能通过一条命令把当前配置用到的所有文件,按现有目录组织复制到指定文件夹,过滤未用到的文件.这样即便不使用默认编译器或不使用scons的环境,也能很快移植完.因为,当前配置所用到的文件都有了.只需修改到能编译链接通过就差不多了

    本帖最后由 漫漫朔雪 于 2018-7-9 23:40 编辑


又出现重复定义,@yqiu怎么处理. 这个C++特性支持,我们不一定用,我就是想试下各个可能用到的模块是否能正常编译通过。

9. 修改SConstruct,相关部分改为如下:
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
CXX = rtconfig.CC, CXXFLAGS = rtconfig.CXXFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)

增加CXX和CXXFLGAS。
10. 修改rtconfig.py,增加“CXXFLAGS = CFLAGS”
11. 执行scons编译,仍然如下:
__________________________________
...........

CC build\kernel\src\signal.o
CC build\kernel\src\thread.o
CC build\kernel\src\timer.o
LINK rtthread-beaglebone.elf
build\kernel\components\cplusplus\crt_init.o: In function `_init':
D:\work\env\rt-thread-3.0.4\components\cplusplus/crt_init.c:40: multiple definition of `_init'
d:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/softfp/crti.o:(.init+0x0): first defined here
build\kernel\components\cplusplus\crt_init.o: In function `_fini':
D:\work\env\rt-thread-3.0.4\components\cplusplus/crt_init.c:44: multiple definition of `_fini'
d:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/softfp/crti.o:(.fini+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
scons: *** [rtthread-beaglebone.elf] Error 1
scons: building terminated because of errors.
___________________________________________________

7. 修改rt_config.py中CXX定义
——————————————————————————————
PREFIX = 'arm-none-eabi-'
CC = PREFIX + 'gcc'
CXX = PREFIX + 'g++'
——————————————————————————————
修改最后一项CXX为:
——————————————————————————————
PREFIX = 'arm-none-eabi-'
CC = PREFIX + 'gcc'
CXX = 'arm-none-eabi-g++'
——————————————————————————————
再次执行scons编译,错误依旧:
————————————————————————————————
g++ -o "build\kernel\components\cplusplus\crt.o" -c -Wall -march=armv7-a -mtune=cortex-a8 -ftree-vectorize -ffast-math -mfpu=vfpv3-d16 -mfloat-abi=softfp -O0 -gdwarf-2 -Wall -DHAVE_CCONFIG_H -DRT_USING_NEWLIB -I. -Iapplications -Idrivers -ID:\work\env\rt-thread-3.0.4\include -ID:\work\env\rt-thread-3.0.4\libcpu\arm\am335x -ID:\work\env\rt-thread-3.0.4\libcpu\arm\common -ID:\work\env\rt-thread-3.0.4\components\cplusplus -ID:\work\env\rt-thread-3.0.4\components\dfs\include -ID:\work\env\rt-thread-3.0.4\components\dfs\filesystems\devfs -ID:\work\env\rt-thread-3.0.4\components\dfs\filesystems\elmfat -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\finsh -ID:\work\env\rt-thread-3.0.4\components\libc\compilers\newlib "D:\work\env\rt-thread-3.0.4\components\cplusplus\crt.cpp"
Exception: [Error 2] : No such file or directory
————————————————————————————————————————————
8. 查看D:\work\env\rt-thread-3.0.4\bsp\beaglebone\SConstruct文件,发现以下定义:
_______________________________________________________________________
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
_______________________________________________________________________
修改为(添加了其中CXX,对rtconfig不了解,暂时设置为rtconfig.CC):
_______________________________________________________________________
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CXX = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
_______________________________________________________________________
再次执行scons编译,出现以下问题:
_______________________________________________________________________
> scons
scons: Reading SConscript files ...

scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "D:\work\env\rt-thread-3.0.4\bsp\beaglebone\SConstruct", line 22, in
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CXX build\kernel\components\cplusplus\crt.o
LINK rtthread-beaglebone.elf
build\kernel\src\components.o: In function `rtthread_startup':
D:\work\env\rt-thread-3.0.4\src/components.c:226: multiple definition of `rtthread_startup'
build\applications\startup.o:D:\work\env\rt-thread-3.0.4\bsp\beaglebone/applications/startup.c:29: first defined here
build\kernel\src\components.o: In function `rt_application_init':
D:\work\env\rt-thread-3.0.4\src/components.c:203: multiple definition of `rt_application_init'
build\applications\application.o:D:\work\env\rt-thread-3.0.4\bsp\beaglebone/applications/application.c:23: first defined here
build\kernel\components\cplusplus\crt_init.o: In function `_init':
D:\work\env\rt-thread-3.0.4\components\cplusplus/crt_init.c:40: multiple definition of `_init'
d:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/softfp/crti.o:(.init+0x0): first defined here
build\kernel\components\cplusplus\crt_init.o: In function `_fini':
D:\work\env\rt-thread-3.0.4\components\cplusplus/crt_init.c:44: multiple definition of `_fini'
d:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/softfp/crti.o:(.fini+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
scons: *** [rtthread-beaglebone.elf] Error 1
scons: building terminated because of errors.
____________________________________________________________________________________
但是前面问题没有了,说明跟安装mingw环境有关

@yqiu
步骤:
1. 解压rt-thread-3.0.4.tar.gz到env下.
2. 从D:\work\env\sample下拷贝Kconfig文件到D:\work\env\rt-thread-3.0.4\bsp\beaglebone目录下。
3. 进入D:\work\env\rt-thread-3.0.4\bsp\beaglebone目录,右键选择ConEnv Here,进入env命令行
4. 执行scons编译,这时编译成功。
5. 执行menuconfig. 并选择"Support C++ features",然后保存退出menuconfig.
6. 执行scons编译,结果出错,如下:
_____________________________________________________________________
> scons
scons: Reading SConscript files ...

scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "D:\work\env\rt-thread-3.0.4\bsp\beaglebone\SConstruct", line 22, in
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CC build\applications\application.o
CC build\applications\board.o
CC build\applications\startup.o
CC build\drivers\gpio.o
CC build\drivers\uart.o
CXX build\kernel\components\cplusplus\crt.o
Error in calling:
g++ -o "build\kernel\components\cplusplus\crt.o" -c -Wall -march=armv7-a -mtune=cortex-a8 -ftree-vectorize -ffast-math -mfpu=vfpv3-d16 -mfloat-abi=softfp -O0 -gdwarf-2 -Wall -DHAVE_CCONFIG_H -DRT_USING_NEWLIB -I. -Iapplications -Idrivers -ID:\work\env\rt-thread-3.0.4\include -ID:\work\env\rt-thread-3.0.4\libcpu\arm\am335x -ID:\work\env\rt-thread-3.0.4\libcpu\arm\common -ID:\work\env\rt-thread-3.0.4\components\cplusplus -ID:\work\env\rt-thread-3.0.4\components\dfs\include -ID:\work\env\rt-thread-3.0.4\components\dfs\filesystems\devfs -ID:\work\env\rt-thread-3.0.4\components\dfs\filesystems\elmfat -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\drivers\include -ID:\work\env\rt-thread-3.0.4\components\finsh -ID:\work\env\rt-thread-3.0.4\components\libc\compilers\newlib "D:\work\env\rt-thread-3.0.4\components\cplusplus\crt.cpp"
Exception: [Error 2] : No such file or directory
scons: *** [build\kernel\components\cplusplus\crt.o] Error 2
scons: building terminated because of errors.
_________________________________________________________________________________________

我发现问题所在,是CXX被扩展成"g++“,而不是”arm-none-eabi-g++“。导致问题。但是CC都被正确扩展成”arm-none-eabi-gcc“。rt_config.py文件如下:
_______________________________________________________________________________________________
import os

# toolchains options
ARCH='arm'
CPU='am335x'
CROSS_TOOL='gcc'

if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')

if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = r'C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI\bin'

if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH')

BUILD = 'debug'

if PLATFORM == 'gcc':
# toolchains
PREFIX = 'arm-none-eabi-'
CC = PREFIX + 'gcc'
CXX = PREFIX + 'g++'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
LINK = PREFIX + 'gcc'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'

DEVICE = ' -Wall -march=armv7-a -mtune=cortex-a8'+\
' -ftree-vectorize -ffast-math -mfpu=vfpv3-d16 -mfloat-abi=softfp'
#DEVICE = ' '
CFLAGS = DEVICE
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-beaglebone.map,-cref,-u,Reset_Handler -T beaglebone_ram.lds'

CPATH = ''
LPATH = ''

if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2 -Wall'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2 -Wall'

POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' +\
SIZE + ' $TARGET \n'
________________________________________________________________________________________
是不是scons有bug啊?!

发布
问题