当前位置:网站首页>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
边栏推荐
- Principle and application of single chip microcomputer timer, serial communication and interrupt system
- Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
- 闭包实现迭代器效果
- delete和delete[]引发的问题
- Niuke monthly race 22 tree sub chain
- 3D打印Arduino 四轴飞行器
- Principles of Microcomputer - internal and external structure of microprocessor
- 小鸟识别APP
- How to manage fixed assets efficiently in one stop?
- [pytorch] softmax function
猜你喜欢

Why is the Ltd independent station a Web3.0 website!

2.2 【pytorch】torchvision.transforms

Phishing identification app

Principles of Microcomputer - Introduction

Vsync+ triple cache mechanism +choreographer

I use flask to write the website "one"

How to realize the usage of connecting multiple databases in idel

Which method is good for the management of fixed assets of small and medium-sized enterprises?

【pytorch】2.4 卷积函数 nn.conv2d

2022.02.15_ Daily question leetcode six hundred and ninety
随机推荐
ES6 const essence and completely immutable implementation (object.free)
tensorrt yolov5_ trt. Py comments
Bird recognition app
3D printing Arduino four axis aircraft
Exception handling of classes in C #
Is it safe to dig up money and make new shares
Flink面试题
Why is the Ltd independent station a Web3.0 website!
js重写自己的函数
JS scope chain and closure
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
Can diffusion models be regarded as an autoencoder?
Class loading
Mise en œuvre simple de l'équilibrage de la charge par nacos
Which method is good for the management of fixed assets of small and medium-sized enterprises?
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
2.2 【pytorch】torchvision.transforms
The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
nacos简易实现负载均衡