1.官网下载源码
https://gitee.com/rtthread/rt-thread.git
2.下载编译工具
这个部分参考源码路径下
D:\RT-ThreadStudio\rt-thread\bsp\ls2kdev\README.md
修改编译工具路径
3.下载rtthrad env工具
下载 下载 - RT-Thread物联网操作系统
4.修改源码bug,并编译
原始文件编译错误
欢迎使用 RT-Thread env (V1.2.0) 工具
\ | /
- RT - Thread Operating System
/ | \
2006 - 2019 Copyright by rt-thread team
Online help documents : https://www.rt-thread.org/document/site
abc@LAPTOP-123456 D:\RT-ThreadStudio\rt-thread\bsp\ls2kdev
> scons
scons: Reading SConscript files ...
'D:\RT-ThreadStudio\env_released_1.2.0\env\tools\ConEmu\ConEmu\..\..\..\tools\gnu_gcc\arm_gcc\mingw\bin\mips-sde-elf-gcc' is not recognized as an internal or external command,
operable program or batch file.
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CC build\applications\main.o
CC build\applications\mnt.o
CC build\drivers\board.o
CC build\drivers\clk.o
CC build\drivers\drv_gpio.o
CC build\drivers\drv_pwm.o
CC build\drivers\drv_rtc.o
CC build\drivers\drv_spi.o
drivers\drv_spi.c:28:22: error: unknown type name 'uint8_t'
static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha)
^
drivers\drv_spi.c:28:40: error: unknown type name 'uint8_t'
static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha)
^
drivers\drv_spi.c:28:54: error: unknown type name 'uint8_t'
static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha)
^
drivers\drv_spi.c:38:28: error: unknown type name 'uint8_t'
rt_inline void spi_set_csn(uint8_t val)
^
drivers\drv_spi.c:70:8: error: unknown type name 'uint8_t'
static uint8_t spi_write_for_response(uint8_t data)
^
drivers\drv_spi.c:70:39: error: unknown type name 'uint8_t'
static uint8_t spi_write_for_response(uint8_t data)
^
drivers\drv_spi.c: In function 'cmd_spi_init':
drivers\drv_spi.c:81:5: error: unknown type name 'uint8_t'
uint8_t spre_spr, cpol, cpha;
^
drivers\drv_spi.c: In function 'cmd_spi_set_csn':
drivers\drv_spi.c:103:5: error: unknown type name 'uint8_t'
uint8_t val, csn;
^
drivers\drv_spi.c: In function 'cmd_spi_write':
drivers\drv_spi.c:120:5: error: unknown type name 'uint8_t'
uint8_t data, resp;
^
drivers\drv_spi.c: In function 'configure':
drivers\drv_spi.c:169:5: error: unknown type name 'uint64_t'
uint64_t div = (uint64_t)(spi_max_speed / (float)configuration->max_hz);
^
drivers\drv_spi.c:169:21: error: 'uint64_t' undeclared (first use in this function)
uint64_t div = (uint64_t)(spi_max_speed / (float)configuration->max_hz);
^
drivers\drv_spi.c:169:21: note: each undeclared identifier is reported only once for each function it appears in
drivers\drv_spi.c: In function 'xfer':
drivers\drv_spi.c:191:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
cs = (unsigned char)(device->parent.user_data);
^
scons: *** [build\drivers\drv_spi.o] Error 1
scons: building terminated because of errors.
修改
typedef unsigned char uint8_t;
typedef unsigned long long u64;
typedef unsigned long long uint64_t;
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef signed int s32;
编译通过
编译结果
5.使用网络加载
Press <Enter> to execute loading image:(wd0,0)/boot/vmlinuz
Press any other key to abort. 02
PMON> ifconfig syn0 192.168.186.240
PMON> load tftp://192.168.186.78/rtthread.elf
Loading file: tftp://192.168.186.78/rtthread.elf (elf)
(elf)
0x80200000/798688 + 0x802c2fe0/152192(z) + 1314 syms\
Entry address is 8020024c
PMON> g
当前版本有BUG,网上有人指出RT-Thread-龙芯派 ls2k1000将程序编译下载后运行,出现msh,但几秒后自动关机RT-Thread问答社区 - RT-Thread
版本号
版本log
6.更改版本,重新编译,成功
回退到这个版本
版本回退并清理多余文件
重新编译
驱动比较少