Merge pull request #43 from RT-Thread/master

update
This commit is contained in:
Meco Jianting Man 2021-04-21 05:58:37 +08:00 committed by GitHub
commit 09f04bee8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 105 additions and 22 deletions

View File

@ -7,3 +7,6 @@ file_path:
dir_path:
- tools
- components/net/lwip-1.4.1
- components/net/lwip-2.0.2
- components/net/lwip-2.1.2

View File

@ -300,7 +300,7 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
MMCSD_BUS_WIDTH_1
};
struct rt_mmcsd_host *host = card->host;
unsigned idx, bus_width = 0;
unsigned idx, trys, bus_width = 0;
int err = 0;
if (GET_BITS(card->resp_cid, 122, 4) < 4)
@ -335,10 +335,13 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
if (err)
continue;
bus_width = bus_widths[idx];
mmcsd_set_bus_width(host, bus_width);
mmcsd_delay_ms(20); //delay 10ms
err = mmc_compare_ext_csds(card, ext_csd, bus_width);
for(trys = 0; trys < 5; trys++){
mmcsd_set_bus_width(host, bus_width);
mmcsd_delay_ms(10);
err = mmc_compare_ext_csds(card, ext_csd, bus_width);
if(!err)
break;
}
if (!err) {
err = bus_width;
break;

View File

@ -27,6 +27,7 @@ struct eth_device
rt_uint16_t flags;
rt_uint8_t link_changed;
rt_uint8_t link_status;
rt_uint8_t rx_notice;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);

View File

@ -469,6 +469,8 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
dev->flags = flags;
/* link changed status of device */
dev->link_changed = 0x00;
/* avoid send the same mail to mailbox */
dev->rx_notice = 0x00;
dev->parent.type = RT_Device_Class_NetIf;
/* register to RT-Thread device manager */
rt_device_register(&(dev->parent), name, RT_DEVICE_FLAG_RDWR);
@ -550,10 +552,18 @@ rt_err_t eth_device_init(struct eth_device * dev, const char *name)
rt_err_t eth_device_ready(struct eth_device* dev)
{
if (dev->netif)
{
if(dev->rx_notice == RT_FALSE)
{
dev->rx_notice = RT_TRUE;
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
}
else
return RT_EOK;
/* post message to Ethernet thread */
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
}
else
return ERR_OK; /* netif is not initialized yet, just return. */
return -RT_ERROR; /* netif is not initialized yet, just return. */
}
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
@ -628,6 +638,7 @@ static void eth_rx_thread_entry(void* parameter)
{
if (rt_mb_recv(&eth_rx_thread_mb, (rt_ubase_t*)&device, RT_WAITING_FOREVER) == RT_EOK)
{
rt_base_t level;
struct pbuf *p;
/* check link status */
@ -647,8 +658,13 @@ static void eth_rx_thread_entry(void* parameter)
netifapi_netif_set_link_down(device->netif);
}
level = rt_hw_interrupt_disable();
/* 'rx_notice' will be modify in the interrupt or here */
device->rx_notice = RT_FALSE;
rt_hw_interrupt_enable(level);
/* receive all of buffer */
while (1)
while(1)
{
if(device->eth_rx == RT_NULL) break;

View File

@ -27,6 +27,7 @@ struct eth_device
rt_uint16_t flags;
rt_uint8_t link_changed;
rt_uint8_t link_status;
rt_uint8_t rx_notice;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);

View File

@ -511,6 +511,8 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
dev->flags = flags;
/* link changed status of device */
dev->link_changed = 0x00;
/* avoid send the same mail to mailbox */
dev->rx_notice = 0x00;
dev->parent.type = RT_Device_Class_NetIf;
/* register to RT-Thread device manager */
rt_device_register(&(dev->parent), name, RT_DEVICE_FLAG_RDWR);
@ -599,10 +601,18 @@ void eth_device_deinit(struct eth_device *dev)
rt_err_t eth_device_ready(struct eth_device* dev)
{
if (dev->netif)
{
if(dev->rx_notice == RT_FALSE)
{
dev->rx_notice = RT_TRUE;
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
}
else
return RT_EOK;
/* post message to Ethernet thread */
return rt_mb_send(&eth_rx_thread_mb, (rt_ubase_t)dev);
}
else
return ERR_OK; /* netif is not initialized yet, just return. */
return -RT_ERROR; /* netif is not initialized yet, just return. */
}
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
@ -677,6 +687,7 @@ static void eth_rx_thread_entry(void* parameter)
{
if (rt_mb_recv(&eth_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_FOREVER) == RT_EOK)
{
rt_base_t level;
struct pbuf *p;
/* check link status */
@ -696,8 +707,13 @@ static void eth_rx_thread_entry(void* parameter)
netifapi_netif_set_link_down(device->netif);
}
level = rt_hw_interrupt_disable();
/* 'rx_notice' will be modify in the interrupt or here */
device->rx_notice = RT_FALSE;
rt_hw_interrupt_enable(level);
/* receive all of buffer */
while (1)
while(1)
{
if(device->eth_rx == RT_NULL) break;

View File

@ -27,6 +27,7 @@ struct eth_device
rt_uint16_t flags;
rt_uint8_t link_changed;
rt_uint8_t link_status;
rt_uint8_t rx_notice;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);

View File

@ -514,6 +514,8 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
dev->flags = flags;
/* link changed status of device */
dev->link_changed = 0x00;
/* avoid send the same mail to mailbox */
dev->rx_notice = 0x00;
dev->parent.type = RT_Device_Class_NetIf;
/* register to RT-Thread device manager */
rt_device_register(&(dev->parent), name, RT_DEVICE_FLAG_RDWR);
@ -601,10 +603,18 @@ void eth_device_deinit(struct eth_device *dev)
rt_err_t eth_device_ready(struct eth_device* dev)
{
if (dev->netif)
{
if(dev->rx_notice == RT_FALSE)
{
dev->rx_notice = RT_TRUE;
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
}
else
return RT_EOK;
/* post message to Ethernet thread */
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
}
else
return ERR_OK; /* netif is not initialized yet, just return. */
return -RT_ERROR; /* netif is not initialized yet, just return. */
}
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
@ -679,6 +689,7 @@ static void eth_rx_thread_entry(void* parameter)
{
if (rt_mb_recv(&eth_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_FOREVER) == RT_EOK)
{
rt_base_t level;
struct pbuf *p;
/* check link status */
@ -698,6 +709,11 @@ static void eth_rx_thread_entry(void* parameter)
netifapi_netif_set_link_down(device->netif);
}
level = rt_hw_interrupt_disable();
/* 'rx_notice' will be modify in the interrupt or here */
device->rx_notice = RT_FALSE;
rt_hw_interrupt_enable(level);
/* receive all of buffer */
while (1)
{

View File

@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2019-12-09 Steven Liu the first version
* 2021-04-14 Meco Man Check the file path's legitimacy of 'sy' command
*/
#include <rtthread.h>
@ -219,6 +220,12 @@ static rt_err_t sy(uint8_t argc, char **argv)
const char *file_path;
rt_device_t dev;
if (argc < 2)
{
rt_kprintf("invalid file path.\n");
return -RT_ERROR;
}
if (argc > 2)
dev = rt_device_find(argv[2]);
else

View File

@ -17,6 +17,7 @@ def GenerateCFiles(env,project):
info = utils.ProjectInfo(env)
CC = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
CXX = os.path.join(rtconfig.EXEC_PATH, rtconfig.CXX)
AS = os.path.join(rtconfig.EXEC_PATH, rtconfig.AS)
AR = os.path.join(rtconfig.EXEC_PATH, rtconfig.AR)
LINK = os.path.join(rtconfig.EXEC_PATH, rtconfig.LINK)
@ -28,20 +29,24 @@ def GenerateCFiles(env,project):
if cm_file:
cm_file.write("CMAKE_MINIMUM_REQUIRED(VERSION 3.10)\n\n")
cm_file.write("PROJECT(rtthread C ASM)\n")
cm_file.write("SET(CMAKE_SYSTEM_NAME Generic)\n")
cm_file.write("#SET(CMAKE_VERBOSE_MAKEFILE ON)\n\n")
cm_file.write("SET(CMAKE_C_COMPILER \""+ CC + "\")\n")
cm_file.write("SET(CMAKE_CXX_COMPILER \""+ CXX + "\")\n")
cm_file.write("SET(CMAKE_ASM_COMPILER \""+ AS + "\")\n")
cm_file.write("SET(CMAKE_OBJCOPY \""+ OBJCOPY + "\")\n")
cm_file.write("SET(CMAKE_SIZE \""+ SIZE + "\")\n\n")
cm_file.write("SET(CMAKE_C_FLAGS \""+ rtconfig.CFLAGS + "\")\n")
cm_file.write("SET(CMAKE_CXX_FLAGS \""+ rtconfig.CXXFLAGS + "\")\n")
cm_file.write("SET(CMAKE_ASM_FLAGS \""+ rtconfig.AFLAGS + "\")\n")
cm_file.write("SET(CMAKE_EXE_LINKER_FLAGS \""+ re.sub('-T(\s*)', '-T ${CMAKE_SOURCE_DIR}/',rtconfig.LFLAGS) + "\")\n\n")
cm_file.write("SET(CMAKE_CXX_STANDARD 14)\n")
cm_file.write("PROJECT(rtthread C CXX ASM)\n")
cm_file.write("INCLUDE_DIRECTORIES(\n")
for i in info['CPPPATH']:
cm_file.write( "\t" +i + "\n")
@ -59,6 +64,20 @@ def GenerateCFiles(env,project):
cm_file.write( "\t"+os.path.normpath(f.rfile().abspath)+"\n" )
cm_file.write(")\n\n")
cm_file.write("LINK_DIRECTORIES(\n")
for group in project:
if 'LIBPATH' in group.keys():
for f in group['LIBPATH']:
cm_file.write( "\t"+ f + "\n" )
cm_file.write(")\n\n")
cm_file.write("LINK_LIBRARIES(\n")
for group in project:
if 'LIBS' in group.keys():
for f in group['LIBS']:
cm_file.write( "\t"+ "{}\n".format(f))
cm_file.write(")\n\n")
cm_file.write("ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}.elf ${PROJECT_SOURCES})\n")
cm_file.write("ADD_CUSTOM_COMMAND(TARGET ${CMAKE_PROJECT_NAME}.elf POST_BUILD \nCOMMAND ${CMAKE_OBJCOPY} -O binary ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.bin COMMAND ${CMAKE_SIZE} ${CMAKE_PROJECT_NAME}.elf)")