summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Jianting Man <[email protected]>2021-04-21 05:58:37 +0800
committerGitHub <[email protected]>2021-04-21 05:58:37 +0800
commit09f04bee8fef92ace93fb89e498dbf15301448ac (patch)
tree9c0e8b8ed8fbcde5ab196f9af1c1ad690f71497b /components
parent349a85e83f2a9db7786335674bb65d6d1d7f1dab (diff)
parent4188301bda4f7309aa6ee5d3d35b7c65a2b59905 (diff)
Merge pull request #43 from RT-Thread/master
update
Diffstat (limited to 'components')
-rw-r--r--components/drivers/sdio/mmc.c13
-rw-r--r--components/net/lwip-1.4.1/src/include/netif/ethernetif.h1
-rw-r--r--components/net/lwip-1.4.1/src/netif/ethernetif.c28
-rw-r--r--components/net/lwip-2.0.2/src/include/netif/ethernetif.h1
-rw-r--r--components/net/lwip-2.0.2/src/netif/ethernetif.c24
-rw-r--r--components/net/lwip-2.1.2/src/include/netif/ethernetif.h1
-rw-r--r--components/net/lwip-2.1.2/src/netif/ethernetif.c20
-rw-r--r--components/utilities/ymodem/ry_sy.c7
8 files changed, 78 insertions, 17 deletions
diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c
index 5aba3dba7a..d8f3a9e0a5 100644
--- a/components/drivers/sdio/mmc.c
+++ b/components/drivers/sdio/mmc.c
@@ -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;
diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
index 1c969e6e25..650ad32eff 100644
--- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
+++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
@@ -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);
diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c
index f2570f9e2b..4565f5e528 100644
--- a/components/net/lwip-1.4.1/src/netif/ethernetif.c
+++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c
@@ -156,16 +156,16 @@ static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_
static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
{
netdev_low_level_set_dhcp_status(netif, is_enabled);
-
+
if(RT_TRUE == is_enabled)
{
dhcp_start((struct netif *)netif->user_data);
}
else
{
- dhcp_stop((struct netif *)netif->user_data);
+ dhcp_stop((struct netif *)netif->user_data);
}
-
+
return ERR_OK;
}
#endif /* RT_LWIP_DHCP */
@@ -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;
diff --git a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
index 244bafdd1b..1459e3241d 100644
--- a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
+++ b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
@@ -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);
diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c
index b93acb1fcf..1c0f3ca9b2 100644
--- a/components/net/lwip-2.0.2/src/netif/ethernetif.c
+++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c
@@ -173,7 +173,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
}
else
{
- dhcp_stop((struct netif *)netif->user_data);
+ dhcp_stop((struct netif *)netif->user_data);
}
return ERR_OK;
}
@@ -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;
diff --git a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h
index 244bafdd1b..1459e3241d 100644
--- a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h
+++ b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h
@@ -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);
diff --git a/components/net/lwip-2.1.2/src/netif/ethernetif.c b/components/net/lwip-2.1.2/src/netif/ethernetif.c
index 52bd0fb7b6..81dd792f29 100644
--- a/components/net/lwip-2.1.2/src/netif/ethernetif.c
+++ b/components/net/lwip-2.1.2/src/netif/ethernetif.c
@@ -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)
{
diff --git a/components/utilities/ymodem/ry_sy.c b/components/utilities/ymodem/ry_sy.c
index a87f6949db..caad51d6cd 100644
--- a/components/utilities/ymodem/ry_sy.c
+++ b/components/utilities/ymodem/ry_sy.c
@@ -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