当前位置:网站首页>Introduction to mt7628k eCos development
Introduction to mt7628k eCos development
2022-07-01 09:21: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 compile
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
perform make menuconfig There will be a ra305x_ap_adv/ra305x_router/include/autoconf.h file , Because many users generally do not use make menuconfig To configure , Then you can directly modify the file to add the required modules .
1.3 APP Customize a directory
in ra305x_ap_adv/ra305x_router/oem_iot
contain include、Makefile、src
in ra305x_ap_adv/ra305x_router/Makefile
[…]
# oem-begin
APPSUBDIRS += oem_iot
# oem-end
[…]
2 eCos APP Customize 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 Standard drive frame
1) Driver path
in packages/devs/serial/mips/vrc437x
2) modify ecos.db, Compile the driver into the static library
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) Interrupt processing header file
#include <cyg/hal/hal_intr.h>
#include <cyg/hal/drv_api.h>
4 eCos API
4.1 Thread synchronization
Mailbox(cyg_mbox_create)
Mailbox The structure of is a FIFO Circular queue of type , Stored is a pointer .
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 Print UTC Time
#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)
/* The time structure struct tm The value of is converted to the number of seconds elapsed */
// 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;
// Get relative to 1970 The number of seconds to now
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 Write MAC Address
ra0 Of MAC Is read 0x0004、0x0006 and 0x0008 Three registers .
hypothesis MAC Address :00:0C:43:76:20:58
use USB2UART Line entry eCos After the command line .
cd net
iwpriv ra0 e2p 04=0C00
iwpriv ra0 e2p 06=7643
iwpriv ra0 e2p 08=5820
边栏推荐
- 序列化、监听、自定义注解
- Shell script -select in loop
- Latex插入的eps图片模糊解决方法
- Simple load balancing with Nacos
- Can diffusion models be regarded as an autoencoder?
- An overview of the design of royalties and service fees of mainstream NFT market platforms
- 樹結構---二叉樹2非遞歸遍曆
- 树结构---二叉树2非递归遍历
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
- Flink interview questions
猜你喜欢

2.4 activation function

How to solve the problem of fixed assets management and inventory?

Daily practice of C language - day 80: currency change

Principles of Microcomputer - Introduction

Structure de l'arbre - - - arbre binaire 2 traversée non récursive

Implementation and application of queue
![2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data](/img/6e/d8ef618127ac492f5142f7b600266d.png)
2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data

JS prototype chain

【检测技术课案】简易数显电子秤的设计与制作

ESP8266 FreeRTOS开发环境搭建
随机推荐
Summary of reptile knowledge points
JS prototype trap
Pain points and solutions of fixed assets management of group companies
js valueOf 与 toString 区别
Which method is good for the management of fixed assets of small and medium-sized enterprises?
闭包实现迭代器效果
Log4j 日志框架
Vsync+ triple cache mechanism +choreographer
树结构---二叉树1
nacos簡易實現負載均衡
【pytorch】nn. AdaptiveMaxPool2d
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式
Closure implementation iterator effect
How to realize the usage of connecting multiple databases in idel
The fixed assets management system enables enterprises to dynamically master assets
phpexcel 里 获取某一列的列表 获取某一列的字母
【检测技术课案】简易数显电子秤的设计与制作
How to effectively align team cognition
【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino