RTEMS STM32F103RCT6应用

来源:互联网 发布:qq聊天室软件 编辑:程序博客网 时间:2024/04/29 12:53

1.准备工作

安装好RTEMS工具链,ECLIPSE插件,git RTEMS4.11最新代码。

2.安装调试工具

在FEDORA中调试STM32,可以通过GDB来调试,虽然跟在WINDOWS下调试相比易用性相差较大,但是也能达到调试的目的以及实现程序下载的功能。如果用JLINK开始用JLINK的LINUX版的软件,或者OPENOCD。在此我选择的是JLINK。下载到jlink-4.98.1.x86_64.rpm,直接安装即可。

2.STM32F103RCT6应用

在编译好STM32F103的BSP之后,在ECLIPSE中建立工程:


然后设置工具链及BSP:


然后配置外部工具,在程序项里新建JLINK,然后配置,在此我使用的SWD的调试方式。在调试的时候,先用外部工具启动JLINK。


GDB调试配置。在调试配置中,GDB HARDWARE DEBUGGING中,新建一个调试,然后搜索项目,将自己的当前项目添加进去,一般是RTEMS Executable Configuration/xxx.exe,然后在DEBUGGER选项中设置为GDB TCP/IP localhost 端口:2331


在STARTUP选项中的初始化命令中设置:

    monitor flash device = STM32F103RC
    monitor flash download = 1
    monitor flash breakpoints = 1
   monitor clrbp
    monitor endian little
    monitor speed 5
    monitor reset
    monitor sleep 100
    monitor speed auto

执行命令中设置:

monitor reg r13 = (0x00000000)
monitor reg pc = (0x00000004)
break Init
continue


然后就可以下载调试了。调试的时候,在已经启动了外部工具JLINK的情况下,然后再启动调试。

STM32F103RCT6的应用BSP的参考配置:

/**************** START OF CONFIGURATION INFORMATION ****************/

#define CONFIGURE_INIT

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_FILESYSTEM_MINIIMFS
#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
//#define CONFIGURE_TERMIOS_DISABLED
//#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS     0
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS         13
#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
#define CONFIGURE_MINIMUM_TASK_STACK_SIZE                 2048
#define CONFIGURE_MAXIMUM_PRIORITY 15
#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
#define CONFIGURE_IDLE_TASK_BODY Init
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION

#define CONFIGURE_MAXIMUM_TASKS                         6
#define CONFIGURE_MAXIMUM_SEMAPHORES                    16
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES                 5

#include <rtems/confdefs.h>
#ifndef CONFIGURE_MAXIMUM_DRIVERS
  #define CONFIGURE_MAXIMUM_DRIVERS
#endif
rtems_driver_address_table
_IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = {
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
    CONSOLE_DRIVER_TABLE_ENTRY,
#endif
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    CLOCK_DRIVER_TABLE_ENTRY,
#endif
    ADC_DRIVER_TABLE_ENTRY,
    DAC_DRIVER_TABLE_ENTRY,
    NULL_DRIVER_TABLE_ENTRY
};

STM32F103CBT6 APP的参考配置:

/* configuration information */
//#define CONFIGURE_INIT
/*
 * This application has no device drivers.
 */
/* NOTICE: the clock driver is explicitly disabled */
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
//#define CONFIGURE_APPLICATION_DISABLE_CLOCK_DRIVER
/*
 *  This application has no filesytem and libio support.
 */
#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM

/*
 *  This disables reentrancy support in the C Library.  It is usually
 *  not something an application wants to do unless the development
 *  team is committed to using C Library routines that are KNOWN to
 *  be reentrant.  Caveat Emptor!!
 */
#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY

/*
 *  This test does not need the console driver so there is no reason
 *  to configure termios.
 */
#define CONFIGURE_TERMIOS_DISABLED

/*
 *  This test does not use any stdio.
 */
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 0

/*
 *  This may prevent us from running on every architecture but it
 *  demonstrates that the user can specify how small of a minimum
 *  stack they want.
 */
#define CONFIGURE_MINIMUM_TASK_STACK_SIZE 512

/*
 *  This lowers the number of priorities that this test is able to
 *  use.  The Idle task will be running at the lowest priority.
 */
#define CONFIGURE_MAXIMUM_PRIORITY 15

/*
 *  This configures RTEMS to use a single memory pool for the RTEMS Workspace
 *  and C Program Heap.  If not defined, there will be separate memory pools
 *  for the RTEMS Workspace and C Program Heap.  Having separate pools
 *  does haved some advantages in the event a task blows a stack or writes
 *  outside its memory area. However, in low memory systems the overhead of
 *  the two pools plus the potential for unused memory in either pool is
 *  very undesirable.
 *
 *  In high memory environments, this is desirable when you want to use
 *  the RTEMS "unlimited" objects option.  You will be able to create objects
 *  until you run out of memory.
 */
#define CONFIGURE_UNIFIED_WORK_AREAS

/*
 *  In this application, the initialization task performs the system
 *  initialization and then transforms itself into the idle task.
 */
#define CONFIGURE_IDLE_TASK_BODY Init
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION

#define CONFIGURE_MAXIMUM_TASKS                                         3
#define CONFIGURE_MAXIMUM_SEMAPHORES                                    5
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES                                 3

/*
 *  If you are debugging confdefs.h, define this
 */
 #define CONFIGURE_CONFDEFS_DEBUG

/*
 *  Instantiate the configuration tables.
 */
#define CONFIGURE_INIT

因为CBT6的RAM空间不够,所以没有使用文件系统,采用最小配置。采用-Os的优化的情况下,最小系统消耗的ROM大约在30K不到。

0 0
原创粉丝点击