当前位置:网站首页>MT7628K eCos开发入门
MT7628K eCos开发入门
2022-07-01 09:17:00 【SEP5010】
0 Preface
MT72628K integrates multi-port ethernet switch, but in our project we don't use it, we only use apcli function.
1 Build
1.1 eCos编译
1)
apt-get install dos2unix
tar -jxvf 2016_0905_eCos_SDK_V3.1.4.0_DPA.tar.bz2
2)
cd eCos_SDK
make clean; make
3)
eCos.img is produced in the “ra305x_ap_adv/ra305x_router”directory
4)
make module_clean; make module
1.2 eCos make menuconfig
执行make menuconfig时会产生一个ra305x_ap_adv/ra305x_router/include/autoconf.h文件,由于很多用户一般不会用make menuconfig来做配置,那么可以直接修改该文件添加需要的模块。
1.3 APP自定义一个目录
in ra305x_ap_adv/ra305x_router/oem_iot
包含include、Makefile、src
in ra305x_ap_adv/ra305x_router/Makefile
[…]
# oem-begin
APPSUBDIRS += oem_iot
# oem-end
[…]
2 eCos APP自定义section
1)
in ra305x_ap_adv/ra305x_router/arch/mips/target.ld
in 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
[...]
}
2)
in 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
[…]
3)
in 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 eCos标准驱动框架
1)驱动路径
in packages/devs/serial/mips/vrc437x
2)修改ecos.db,将驱动编译进静态库
in packages/ecos.db
package CYGPKG_IO_SERIAL_MIPS_VRC437X {
alias { "VRC437X serial device drivers"
devs_serial_mips_vrc437x
vrc437x_serial_driver }
hardware
directory devs/serial/mips/vrc437x
script ser_mips_vrc437x.cdl
description "VRC437X serial device drivers"
}
3)中断处理头文件
#include <cyg/hal/hal_intr.h>
#include <cyg/hal/drv_api.h>
4 eCos API
4.1 线程同步
Mailbox(cyg_mbox_create)
Mailbox的结构是一个FIFO类型的循环队列,存储的是指针。
4.2 CFG API
static void api_usage_test(void)
{
cyg_uint64 c_time;
char line[8];
unsigned long tv_sec, tv_usec;
c_time = cyg_current_time();
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);
}
4.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)
/* 将时间结构体struct tm的值转化为经过的秒数 */
// time_t mktime(struct tm *tm)
/* translate " DD-mth-YY HH:MM:SS GMT" to elapsed seconds */
// time_t tdate_parse( char* str)
API void get_now_time(void)
{
struct timespec time;
struct tm nowtime;
//获取相对于1970到现在的秒数
clock_gettime(CLOCK_REALTIME, &time);
localtime_r(&time.tv_sec, &nowtime);
diag_printf(
"%04d%02d%02d%02d:%02d:%02d\n",
nowtime.tm_year + 1900,
nowtime.tm_mon + 1,
nowtime.tm_mday,
nowtime.tm_hour,
nowtime.tm_min,
nowtime.tm_sec);
}
5 eCos写MAC地址
ra0的MAC是读取0x0004、0x0006和0x0008三个寄存器。
假设MAC地址:00:0C:43:76:20:58
用USB2UART线进入eCos命令行后。
cd net
iwpriv ra0 e2p 04=0C00
iwpriv ra0 e2p 06=7643
iwpriv ra0 e2p 08=5820
边栏推荐
- [pytorch] 2.4 convolution function nn conv2d
- js valueOf 与 toString 区别
- 2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data
- [ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
- TV size and viewing distance
- Is it safe to dig up money and make new shares
- 【检测技术课案】简易数显电子秤的设计与制作
- Record a redis timeout
- How to manage fixed assets well? Easy to point and move to provide intelligent solutions
- Installing Oracle EE
猜你喜欢

TV size and viewing distance

Installation and use of NoSQL database

【电赛训练】红外光通信装置 2013年电赛真题

Jetson nano installs tensorflow GPU and problem solving

小鸟识别APP

队列的实现和应用

Simple load balancing with Nacos
![[pytorch] 2.4 convolution function nn conv2d](/img/eb/382a00af5f88d5954f10ea76343d6e.png)
[pytorch] 2.4 convolution function nn conv2d

Mise en œuvre simple de l'équilibrage de la charge par nacos
![[video game training] real topic of 2013 video game of infrared optical communication device](/img/ef/c2c45c1c6c24aed0a4e93101047372.png)
[video game training] real topic of 2013 video game of infrared optical communication device
随机推荐
【pytorch】nn.AdaptiveMaxPool2d
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
Vsync+ triple cache mechanism +choreographer
Football and basketball game score live broadcast platform source code /app development and construction project
js valueOf 与 toString 区别
Learning practice: comprehensive application of cycle and branch structure (II)
【pytorch】nn. AdaptiveMaxPool2d
How to effectively align team cognition
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
闭包实现迭代器效果
Tree structure --- binary tree 1
Nacos service configuration and persistence configuration
Shell script - special variables: shell $, $*, [email protected], $$$
Log4j 日志框架
Naoqi robot summary 28
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
Shell script -select in loop