Fix
This commit is contained in:
parent
9b60ed210b
commit
4102b5c52d
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "lwip"]
|
|
||||||
path = lwip
|
|
||||||
url = git@github.com:lwip-tcpip/lwip.git
|
|
@ -7,7 +7,7 @@ project(stm32)
|
|||||||
|
|
||||||
add_subdirectory(bsp) #application
|
add_subdirectory(bsp) #application
|
||||||
add_subdirectory(lib) #stm32f4xx library
|
add_subdirectory(lib) #stm32f4xx library
|
||||||
add_subdirectory(lwip) #lwip library
|
# add_subdirectory(lwip) #lwip library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
## Build
|
||||||
|
### Manual Build
|
||||||
|
$cmake -S . -B build
|
||||||
|
cmake --build build
|
||||||
|
### Auto Build
|
||||||
|
$./bld
|
||||||
|
The executables located in the bin directory
|
@ -4,21 +4,30 @@ project(${target_base_name})
|
|||||||
|
|
||||||
set(elf_file ${target_base_name}.elf)
|
set(elf_file ${target_base_name}.elf)
|
||||||
|
|
||||||
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/lwip)
|
# set(LWIP_SOURCE_DIR ${CMAKE_SOURCE_DIR}/lwip)
|
||||||
|
# file(GLOB_RECURSE LWIP_SOURCES ${LWIP_SOURCE_DIR}/*.c)
|
||||||
find_package(LwIP REQUIRED)
|
|
||||||
|
|
||||||
add_executable(${elf_file}
|
add_executable(${elf_file}
|
||||||
${CMAKE_SOURCE_DIR}/app/app.c
|
${CMAKE_SOURCE_DIR}/app/app.c
|
||||||
bsp.c
|
bsp.c
|
||||||
main.c
|
main.c
|
||||||
syscalls.c
|
syscalls.c
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/core/init.c
|
||||||
|
# ${LWIP_SOURCES}
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/core/netif.c
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/core/udp.c
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/core/mem.c
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/core/sys.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${elf_file} PRIVATE
|
target_include_directories(${elf_file} PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/app
|
${CMAKE_SOURCE_DIR}/app
|
||||||
${CMAKE_SOURCE_DIR}/bsp
|
${CMAKE_SOURCE_DIR}/bsp
|
||||||
|
${CMAKE_SOURCE_DIR}/lwip
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/include
|
||||||
# ${CMAKE_SOURCE_DIR}/lwip/src/include/lwip
|
# ${CMAKE_SOURCE_DIR}/lwip/src/include/lwip
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/src/include/netif
|
||||||
|
# ${CMAKE_SOURCE_DIR}/lwip/system/
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(${elf_file} PRIVATE -Wall -Wextra -Os)
|
target_compile_options(${elf_file} PRIVATE -Wall -Wextra -Os)
|
||||||
|
53
bsp/bsp.c
53
bsp/bsp.c
@ -94,37 +94,36 @@ void usart_init() {
|
|||||||
const uint8_t MAC_ADDR[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
|
const uint8_t MAC_ADDR[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
|
||||||
const uint8_t PHY_ADDR = 0x00;
|
const uint8_t PHY_ADDR = 0x00;
|
||||||
|
|
||||||
|
#define IP_ADDR0 192
|
||||||
|
#define IP_ADDR1 168
|
||||||
|
#define IP_ADDR2 0
|
||||||
|
#define IP_ADDR3 5
|
||||||
|
|
||||||
|
#define NETMASK_ADDR0 255
|
||||||
|
#define NETMASK_ADDR1 255
|
||||||
|
#define NETMASK_ADDR2 255
|
||||||
|
#define NETMASK_ADDR3 0
|
||||||
|
|
||||||
|
#define GW_ADDR0 192
|
||||||
|
#define GW_ADDR1 168
|
||||||
|
#define GW_ADDR2 0
|
||||||
|
#define GW_ADDR3 1
|
||||||
|
|
||||||
|
// static struct udp_pcb *echo_pcb;
|
||||||
|
// static char echo_buffer[128];
|
||||||
|
// static ip_addr_t ipaddr, netmask, gw;
|
||||||
|
// static struct netif gnetif;
|
||||||
void eth_init() {
|
void eth_init() {
|
||||||
ETH_InitTypeDef ETH_InitStructure;
|
// lwip_init();
|
||||||
|
|
||||||
ETH_DeInit();
|
|
||||||
ETH_SoftwareReset();
|
|
||||||
printf("Eth reseting...\r\n");
|
|
||||||
while (ETH_GetSoftwareResetStatus() == SET);
|
|
||||||
printf("Done\r\n");
|
|
||||||
|
|
||||||
ETH_MACAddressConfig(ETH_MAC_Address0, MAC_ADDR);
|
|
||||||
|
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_ETH_MAC | RCC_AHB1Periph_ETH_MAC_Tx | RCC_AHB1Periph_ETH_MAC_Rx, ENABLE);
|
|
||||||
ETH_StructInit(Ð_InitStructure);
|
|
||||||
ETH_InitStructure.ETH_AutoNegotiation = ETH_AutoNegotiation_Enable;
|
|
||||||
ETH_InitStructure.ETH_Speed = ETH_Speed_100M;
|
|
||||||
ETH_InitStructure.ETH_Mode = ETH_Mode_FullDuplex;
|
|
||||||
ETH_InitStructure.ETH_LoopbackMode = ETH_LoopbackMode_Disable;
|
|
||||||
ETH_InitStructure.ETH_RetryTransmission = ETH_RetryTransmission_Disable;
|
|
||||||
ETH_InitStructure.ETH_AutomaticPadCRCStrip = ETH_AutomaticPadCRCStrip_Disable;
|
|
||||||
ETH_InitStructure.ETH_ReceiveAll = ETH_ReceiveAll_Enable;
|
|
||||||
|
|
||||||
ETH_InitStructure.ETH_BroadcastFramesReception = ETH_BroadcastFramesReception_Enable;
|
|
||||||
ETH_InitStructure.ETH_PromiscuousMode = ETH_PromiscuousMode_Disable;
|
|
||||||
ETH_InitStructure.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_Perfect;
|
|
||||||
ETH_InitStructure.ETH_UnicastFramesFilter = ETH_UnicastFramesFilter_Perfect;
|
|
||||||
|
|
||||||
|
|
||||||
EthStatus = ETH_Init(Ð_InitStructure, PHY_ADDR);
|
// IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
|
||||||
printf("Eth init with status: %d\r\n", EthStatus);
|
// IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
// IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
|
||||||
ETH_Start();
|
// netif_set_ipaddr(&gnetif, &ipaddr);
|
||||||
|
// netif_set_netmask(&gnetif, &netmask);
|
||||||
|
// netif_set_gw(&gnetif, &gw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_init() {
|
void board_init() {
|
||||||
|
@ -60,7 +60,7 @@ int _getpid(void)
|
|||||||
|
|
||||||
int _kill(int pid, int sig)
|
int _kill(int pid, int sig)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
// errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ caddr_t _sbrk(int incr)
|
|||||||
{
|
{
|
||||||
// write(1, "Heap and stack collision\n", 25);
|
// write(1, "Heap and stack collision\n", 25);
|
||||||
// abort();
|
// abort();
|
||||||
errno = ENOMEM;
|
// errno = ENOMEM;
|
||||||
return (caddr_t) -1;
|
return (caddr_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,13 +147,13 @@ int _open(char *path, int flags, ...)
|
|||||||
|
|
||||||
int _wait(int *status)
|
int _wait(int *status)
|
||||||
{
|
{
|
||||||
errno = ECHILD;
|
// errno = ECHILD;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _unlink(char *name)
|
int _unlink(char *name)
|
||||||
{
|
{
|
||||||
errno = ENOENT;
|
// errno = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,18 +170,18 @@ int _stat(char *file, struct stat *st)
|
|||||||
|
|
||||||
int _link(char *old, char *new)
|
int _link(char *old, char *new)
|
||||||
{
|
{
|
||||||
errno = EMLINK;
|
// errno = EMLINK;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _fork(void)
|
int _fork(void)
|
||||||
{
|
{
|
||||||
errno = EAGAIN;
|
// errno = EAGAIN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _execve(char *name, char **argv, char **env)
|
int _execve(char *name, char **argv, char **env)
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
// errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user