The Build. 1
1.1 eCos compilation environment is provided
. 1)
APT-GET the install the dos2unix
the tar -jxvf 2016_0905_eCos_SDK_V3.1.4.0_DPA.tar.bz2
2)
CD eCos_SDK
the make Clean; the make
. 3)
eCos.img The IS Produced in "ra305x_ap_adv / ra305x_router" Directory
. 4 )
the make module_clean; Module1 the make
1.2 eCos the make menuconfig
generates a ra305x_ap_adv / ra305x_router / include / autoconf.h file execution make menuconfig, as many users do not generally configured with menuconfig make, it can be directly added to modify the required file module.
1.3 APP custom directory
@ ra305x_ap_adv / ra305x_router / oem_iot
comprising the include, the Makefile, the src
@ ra305x_ap_adv / ra305x_router / the Makefile
[...]
# OEM the begin-
APPSUBDIRS + = oem_iot
# OEM-End
[...]
2 eCos APP自定义section
[@ra305x_ap_adv/ra305x_router/arch/mips/target.ld]
@ra305x_ap_adv/ra305x_router/target.ld
SECTIONS
{
[...]
.text ALIGN (0x4) :
{
[...]
. = ALIGN(4);
PROVIDE (__core_initcall = .);
KEEP(*(.core.initcall))
PROVIDE (__core_initcall_end = .);
. = ALIGN(4);
PROVIDE (__module_initcall = .);
KEEP(*(.module.initcall))
PROVIDE (__module_initcall_end = .);
. = ALIGN(4);
PROVIDE (__late_initcall = .);
KEEP(*(.late.initcall))
PROVIDE (__late_initcall_end = .);
[...]
} > ram =0
[...]
}
@ra305x_ap_adv/ra305x_router/oem_iot/include/oem_portmisc.h
[…]
typedef void (*initcall_t)(void);
extern initcall_t __core_initcall[];
extern initcall_t __core_initcall_end[];
extern initcall_t __module_initcall[];
extern initcall_t __module_initcall_end[];
extern initcall_t __late_initcall[];
extern initcall_t __late_initcall_end[];
#if 1
#define core_initcall(fn) \
static initcall_t __initcall_##fn \
__attribute__((used,section(".core.initcall"))) = fn
#define module_init(fn) \
static initcall_t __initcall_##fn \
__attribute__((used,section(".module.initcall"))) = fn
#define late_initcall(fn) \
static initcall_t __initcall_##fn \
__attribute__((used,section(".late.initcall"))) = fn
#else
#define core_initcall(fn) \
void fn(void) __attribute__((unused))
#define module_init(fn) \
void fn(void) __attribute__((unused))
#define late_initcall(fn) \
void fn(void) __attribute__((unused))
#endif
[…]
@ra305x_ap_adv/ra305x_router/init/main.c
/* oem-begin */
#include "../oem_iot/include/oem_portmisc.h"
/* oem-end */
static void section_core_init(void)
{
initcall_t *initcall;
for (initcall = __core_initcall;
initcall < __core_initcall_end;
initcall++) {
(*initcall)();
}
}
static void section_module_init(void)
{
initcall_t *initcall;
for (initcall = __module_initcall;
initcall < __module_initcall_end;
initcall++) {
(*initcall)();
}
}
static void section_late_init(void)
{
initcall_t *initcall;
for (initcall = __late_initcall;
initcall < __late_initcall_end;
++ initcall,) {
(* initcall,) ();
}
}
. 3 Add a drive (example)
3.1 eCos standard drive frame
1) drive path
@ Packages / devs / Serial / MIPS / vrc437x /
2) Modify ecos.db, compiled into the driving static library
@ Packages Standard Package / ecos.db
Package Penalty for CYGPKG_IO_SERIAL_MIPS_VRC437X {
Alias { "VRC437X the Drivers Serial Device"
devs_serial_mips_vrc437x vrc437x_serial_driver}
Hardware
Directory devs / Serial / mips / vrc437x
Script ser_mips_vrc437x.cdl
the Description "Serial Device VRC437X the Drivers"
}
3.2 framework do not
interrupt handler needs to contain the following 2 header file:
#include <Cyg / HAL / hal_intr.h>
#include <Cyg / HAL / drv_api.h>
4 Taglist
4.1 from the Download taglist.vim Internet
need to register an account
4.2 the Install
4.2.1 ~ / .vimrc Setting
Copy the Comment at The following to ~ / .vimrc
or less "(left double quotation marks) the latter represent comments
example: "Always Show the Tlist
" Always Show the Tlist
the let Tlist_Show_One_File. 1 =
the let Tlist_Exit_OnlyWindow. 1 =
the let Tlist_Auto_Open. 1 =
the let Tlist_WinWidth = 30
4.2.2 taglist.vim
mkdir ~ / .vim / plugin
CP taglist.vim ~ /. vim / plugin
4.2.3 the taglist shortcut
jump to the left function list window: ctrl + w key is pressed twice
to jump to the right window Source: selection function, pressing the Enter key
when the function list on the left window is closed, with the vim open the following command: ": TlistOpen"
needs to close the left window list function, may be as follows in order to close with vim: ": TlistClose"
Or use the "ctrl + w 2 key press the" Go to the left of the window, and then enter the following command: ": Q"
4.3 The Whitespace the Show
the Copy to Comment The following ~ / .vimrc
less "(left double quotes) represents the back Notes
For example: "whitespace
" whitespace
highlight whitespaceEOF ctermbg = Red guibg = Red
match whitespaceEOF / \ S \ + $ /
vim look at the code detailed configuration, see separate blog post "Cscope How-to"
5 API
5.1 thread synchronization
Mailbox (cyg_mbox_create )
Mailbox structure is a FIFO type of a circular queue of pointers.
5.2 of CFG the API
static void api_usage_test (void)
{
cyg_uint64 c_time;
char Line [. 8];
unsigned Long the tv_sec, tv_usec;
c_time = cyg_current_time ();
the tv_sec = (u_long) (c_time / 100) ;
tv_usec = (((u_long)ctime)%100) * 10000;
diag_printf("tv_sec: %ld, tv_usec: %ld\n", tv_sec, tv_usec);
// interface_config();
CFG_get_str(CFG_SYS_OPMODE, line);
diag_printf("opmode: %d\n", strtol(line, NULL, 10));
CFG_reset_default();
//mon_snd_cmd(MON_CMD_REBOOT);
}
5.3 打印UTC时间
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
// time_t gmt_translate2localtime(time_t gmt_time)
// struct tm *gmtime(const time_t *timep)
/ * Translate the value of the time structure struct tm is the number of seconds * /
// time_t the mktime (struct tm * (TM))
/ * Translate "MTH-DD-YY HH: the MM: the SS GMT" Elapsed seconds The to * /
/ / time_t tdate_parse (char * STR)
the API get_now_time void (void)
{
struct the timespec Time;
struct (TM) nowtime;
clock_gettime (the CLOCK_REALTIME, & Time); // Get current with respect to 1970 seconds
localtime_r (& time.tv_sec, & nowtime) ;
diag_printf ( "% 02d 02d% 04D%% 02d:% 02d:% 02d \ n-", nowtime.tm_year + 1900,
nowtime.tm_mon +. 1, nowtime.tm_mday,
nowtime.tm_hour, nowtime.tm_min, nowtime.tm_sec);
}
. 6 URLs
eCos detailed memory layout file
http://velep.com/archives/579.html
eCos How-to
Guess you like
Origin blog.csdn.net/zoosenpin/article/details/73479921
Ranking