summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authoraozima <[email protected]>2020-10-09 15:17:27 +0800
committeraozima <[email protected]>2020-10-09 15:17:27 +0800
commit05777266b9dffe30df0bef15b35b710f6de21710 (patch)
tree6453a68327fd2d7ffb3dcbf788bd5f6d8b209528 /components
parent79fd12842beeee5a653ba6f4bc2f08b21be7697a (diff)
parentaeff91b2a7fc846cf3724c01c28fbd7327bd2bac (diff)
Merge remote-tracking branch 'remotes/gitee/master' into gitee_master
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/devfs/devfs.c2
-rw-r--r--components/dfs/include/dfs.h1
-rw-r--r--components/dfs/src/dfs.c1
-rw-r--r--components/dfs/src/dfs_file.c2
-rw-r--r--components/drivers/include/drivers/pin.h3
-rw-r--r--components/drivers/misc/pin.c15
-rw-r--r--components/drivers/sensors/sensor.c3
-rwxr-xr-xcomponents/drivers/sensors/sensor.h10
-rwxr-xr-xcomponents/drivers/sensors/sensor_cmd.c3
-rw-r--r--components/drivers/serial/serial.c15
-rw-r--r--components/drivers/spi/sfud/inc/sfud_flash_def.h10
-rw-r--r--components/drivers/spi/spi_msd.c10
-rw-r--r--components/drivers/src/dataqueue.c1
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c5
-rw-r--r--components/drivers/usb/usbdevice/class/hid.c18
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.c26
-rw-r--r--components/drivers/usb/usbhost/core/usbhost_core.c8
-rw-r--r--components/libc/Kconfig8
-rw-r--r--components/libc/compilers/armlibc/fcntl.h2
-rw-r--r--components/libc/compilers/armlibc/sys/ioctl.h (renamed from components/libc/compilers/dlib/termios.h)8
-rw-r--r--components/libc/compilers/armlibc/sys/types.h8
-rw-r--r--components/libc/compilers/armlibc/sys/unistd.h4
-rw-r--r--components/libc/compilers/armlibc/unistd.h1
-rw-r--r--components/libc/compilers/common/SConscript11
-rw-r--r--components/libc/compilers/common/readme.md1
-rw-r--r--components/libc/compilers/common/sys/time.h26
-rw-r--r--components/libc/compilers/common/termios.h (renamed from components/libc/compilers/armlibc/termios.h)2
-rw-r--r--components/libc/compilers/common/time.c1
-rw-r--r--components/libc/compilers/common/unistd.c26
-rw-r--r--components/libc/compilers/dlib/sys/unistd.h4
-rw-r--r--components/libc/compilers/minilibc/SConscript2
-rw-r--r--components/libc/compilers/newlib/termios.h15
-rw-r--r--components/libc/compilers/newlib/time.c82
-rw-r--r--components/libc/getline/README.md30
-rw-r--r--components/libc/getline/SConscript13
-rw-r--r--components/libc/getline/UNLICENSE24
-rw-r--r--components/libc/getline/posix_getline.c79
-rw-r--r--components/libc/getline/posix_getline.h24
-rw-r--r--components/libc/termios/posix_termios.c9
-rw-r--r--components/libc/termios/posix_termios.h4
-rw-r--r--components/net/Kconfig6
-rw-r--r--components/net/lwip-1.4.1/src/arch/include/arch/cc.h2
-rw-r--r--components/net/lwip-2.0.2/src/arch/include/arch/cc.h2
-rw-r--r--components/net/lwip-2.0.2/src/arch/sys_arch.c4
-rw-r--r--components/net/lwip-2.0.2/src/lwipopts.h5
-rw-r--r--components/net/lwip-2.0.2/src/netif/ethernetif.c19
-rw-r--r--components/net/lwip-2.1.2/src/arch/include/arch/cc.h2
-rw-r--r--components/net/uip/rt-thread/uip_ethernetif.c12
-rw-r--r--components/utilities/ulog/syslog/syslog.c1
-rw-r--r--components/utilities/utest/utest.h1
50 files changed, 388 insertions, 183 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c
index 936b074ce1..7637074dbb 100644
--- a/components/dfs/filesystems/devfs/devfs.c
+++ b/components/dfs/filesystems/devfs/devfs.c
@@ -186,6 +186,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
result = file->fops->open(file);
if (result == RT_EOK || result == -RT_ENOSYS)
{
+ file->type = FT_DEVICE;
return 0;
}
}
@@ -197,6 +198,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
if (result == RT_EOK || result == -RT_ENOSYS)
{
file->data = device;
+ file->type = FT_DEVICE;
return RT_EOK;
}
}
diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h
index eb32a4b411..1158df93cb 100644
--- a/components/dfs/include/dfs.h
+++ b/components/dfs/include/dfs.h
@@ -55,6 +55,7 @@
#define FT_SOCKET 1 /* socket file */
#define FT_DIRECTORY 2 /* directory */
#define FT_USER 3 /* user defined */
+#define FT_DEVICE 4 /* device */
/* File flags */
#define DFS_F_OPEN 0x01000000
diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c
index b20de13988..7ace0bc160 100644
--- a/components/dfs/src/dfs.c
+++ b/components/dfs/src/dfs.c
@@ -542,6 +542,7 @@ int list_fd(void)
else if (fd->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file");
else if (fd->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket");
else if (fd->type == FT_USER) rt_kprintf("%-7.7s ", "user");
+ else if (fd->type == FT_DEVICE) rt_kprintf("%-7.7s ", "device");
else rt_kprintf("%-8.8s ", "unknown");
rt_kprintf("%3d ", fd->ref_count);
rt_kprintf("%04x ", fd->magic);
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c
index 91d39597f0..fd205f2f3a 100644
--- a/components/dfs/src/dfs_file.c
+++ b/components/dfs/src/dfs_file.c
@@ -157,7 +157,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
return -EINVAL;
/* regular file system fd */
- if (fd->type == FT_REGULAR)
+ if (fd->type == FT_REGULAR || fd->type == FT_DEVICE)
{
switch (cmd)
{
diff --git a/components/drivers/include/drivers/pin.h b/components/drivers/include/drivers/pin.h
index ca35407932..f5b2ded9f6 100644
--- a/components/drivers/include/drivers/pin.h
+++ b/components/drivers/include/drivers/pin.h
@@ -74,10 +74,13 @@ struct rt_pin_ops
rt_uint32_t mode, void (*hdr)(void *args), void *args);
rt_err_t (*pin_detach_irq)(struct rt_device *device, rt_int32_t pin);
rt_err_t (*pin_irq_enable)(struct rt_device *device, rt_base_t pin, rt_uint32_t enabled);
+ rt_base_t (*pin_get)(const char *name);
};
int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void *user_data);
+/* Get pin number by name,such as PA.0,P0.12 */
+rt_base_t rt_pin_get(const char *name);
void rt_pin_mode(rt_base_t pin, rt_base_t mode);
void rt_pin_write(rt_base_t pin, rt_base_t value);
int rt_pin_read(rt_base_t pin);
diff --git a/components/drivers/misc/pin.c b/components/drivers/misc/pin.c
index aca58ee21b..2750f5105a 100644
--- a/components/drivers/misc/pin.c
+++ b/components/drivers/misc/pin.c
@@ -151,3 +151,18 @@ int rt_pin_read(rt_base_t pin)
return _hw_pin.ops->pin_read(&_hw_pin.parent, pin);
}
FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_read, pinRead, read status from hardware pin);
+
+rt_base_t rt_pin_get(const char *name)
+{
+ RT_ASSERT(_hw_pin.ops != RT_NULL);
+ RT_ASSERT(name[0] == 'P');
+
+ if(_hw_pin.ops->pin_get == RT_NULL)
+ {
+ return -RT_ENOSYS;
+ }
+
+ return _hw_pin.ops->pin_get(name);
+}
+FINSH_FUNCTION_EXPORT_ALIAS(rt_pin_get, pinGet, get pin number from hardware pin);
+
diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c
index 08127bc292..eb5c97a574 100644
--- a/components/drivers/sensors/sensor.c
+++ b/components/drivers/sensors/sensor.c
@@ -34,7 +34,8 @@ static char *const sensor_name_str[] =
"step_", /* Step sensor */
"forc_", /* Force sensor */
"dust_", /* Dust sensor */
- "eco2_" /* eCO2 sensor */
+ "eco2_", /* eCO2 sensor */
+ "gnss_" /* GPS/GNSS sensor */
};
/* Sensor interrupt correlation function */
diff --git a/components/drivers/sensors/sensor.h b/components/drivers/sensors/sensor.h
index e61b32acba..99cf073dd0 100755
--- a/components/drivers/sensors/sensor.h
+++ b/components/drivers/sensors/sensor.h
@@ -47,6 +47,7 @@ extern "C" {
#define RT_SENSOR_CLASS_FORCE (13) /* Force sensor */
#define RT_SENSOR_CLASS_DUST (14) /* Dust sensor */
#define RT_SENSOR_CLASS_ECO2 (15) /* eCO2 sensor */
+#define RT_SENSOR_CLASS_GNSS (16) /* GPS/GNSS sensor */
/* Sensor vendor types */
@@ -84,6 +85,8 @@ extern "C" {
#define RT_SENSOR_UNIT_MN (13) /* Force unit: mN */
#define RT_SENSOR_UNIT_PPM (14) /* Concentration unit: ppm */
#define RT_SENSOR_UNIT_PPB (15) /* Concentration unit: ppb */
+#define RT_SENSOR_UNIT_DMS (16) /* Coordinates unit: DMS */
+#define RT_SENSOR_UNIT_DD (17) /* Coordinates unit: DD */
/* Sensor communication interface types */
@@ -184,6 +187,12 @@ struct sensor_3_axis
rt_int32_t z;
};
+struct coordinates
+{
+ double longitude;
+ double latitude;
+};
+
struct rt_sensor_data
{
rt_uint32_t timestamp; /* The timestamp when the data was received */
@@ -193,6 +202,7 @@ struct rt_sensor_data
struct sensor_3_axis acce; /* Accelerometer. unit: mG */
struct sensor_3_axis gyro; /* Gyroscope. unit: mdps */
struct sensor_3_axis mag; /* Magnetometer. unit: mGauss */
+ struct coordinates coord; /* Coordinates unit: degrees */
rt_int32_t temp; /* Temperature. unit: dCelsius */
rt_int32_t humi; /* Relative humidity. unit: permillage */
rt_int32_t baro; /* Pressure. unit: pascal (Pa) */
diff --git a/components/drivers/sensors/sensor_cmd.c b/components/drivers/sensors/sensor_cmd.c
index d74b1a6307..70e08f601a 100755
--- a/components/drivers/sensors/sensor_cmd.c
+++ b/components/drivers/sensors/sensor_cmd.c
@@ -34,6 +34,9 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
case RT_SENSOR_CLASS_MAG:
LOG_I("num:%3d, x:%5d, y:%5d, z:%5d mGauss, timestamp:%5d", num, sensor_data->data.mag.x, sensor_data->data.mag.y, sensor_data->data.mag.z, sensor_data->timestamp);
break;
+ case RT_SENSOR_CLASS_GNSS:
+ LOG_I("num:%3d, lon:%5d, lat:%5d, timestamp:%5d", num, sensor_data->data.coord.longitude, sensor_data->data.coord.latitude, sensor_data->timestamp);
+ break;
case RT_SENSOR_CLASS_TEMP:
LOG_I("num:%3d, temp:%3d.%d C, timestamp:%5d", num, sensor_data->data.temp / 10, sensor_data->data.temp % 10, sensor_data->timestamp);
break;
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index c442b052b1..2511f18102 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -22,6 +22,8 @@
* 2017-11-15 JasonJia fix poll rx issue when data is full.
* add TCFLSH and FIONREAD support.
* 2018-12-08 Ernest Chen add DMA choice
+ * 2020-09-14 WillianChan add a line feed to the carriage return character
+ * when using interrupt tx
*/
#include <rthw.h>
@@ -315,6 +317,19 @@ rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t *
while (length)
{
+ /*
+ * to be polite with serial console add a line feed
+ * to the carriage return character
+ */
+ if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM))
+ {
+ if (serial->ops->putc(serial, '\r') == -1)
+ {
+ rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER);
+ continue;
+ }
+ }
+
if (serial->ops->putc(serial, *(char*)data) == -1)
{
rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER);
diff --git a/components/drivers/spi/sfud/inc/sfud_flash_def.h b/components/drivers/spi/sfud/inc/sfud_flash_def.h
index 5a7bc8c96a..03b95cd008 100644
--- a/components/drivers/spi/sfud/inc/sfud_flash_def.h
+++ b/components/drivers/spi/sfud/inc/sfud_flash_def.h
@@ -87,7 +87,7 @@ typedef struct {
#define SFUD_MF_ID_FUDAN 0xA1
#define SFUD_MF_ID_HYUNDAI 0xAD
#define SFUD_MF_ID_SST 0xBF
-#define SFUD_MF_ID_MICRONIX 0xC2
+#define SFUD_MF_ID_MACRONIX 0xC2
#define SFUD_MF_ID_GIGADEVICE 0xC8
#define SFUD_MF_ID_ISSI 0xD5
#define SFUD_MF_ID_WINBOND 0xEF
@@ -110,7 +110,7 @@ typedef struct {
{"GigaDevice", SFUD_MF_ID_GIGADEVICE}, \
{"ISSI", SFUD_MF_ID_ISSI}, \
{"Winbond", SFUD_MF_ID_WINBOND}, \
- {"Micronix", SFUD_MF_ID_MICRONIX}, \
+ {"Macronix", SFUD_MF_ID_MACRONIX}, \
}
#ifdef SFUD_USING_FLASH_INFO_TABLE
@@ -144,7 +144,7 @@ typedef struct {
#endif /* SFUD_USING_FLASH_INFO_TABLE */
#ifdef SFUD_USING_QSPI
-/* This table saves flash read-fast instructions in QSPI mode,
+/* This table saves flash read-fast instructions in QSPI mode,
* SFUD can use this table to select the most appropriate read instruction for flash.
* | mf_id | type_id | capacity_id | qspi_read_mode |
*/
@@ -173,7 +173,9 @@ typedef struct {
/* A25LQ64 */ \
{SFUD_MF_ID_AMIC, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_IO}, \
/* MX25L3206E and KH25L3206E */ \
- {SFUD_MF_ID_MICRONIX, 0x20, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT}, \
+ {SFUD_MF_ID_MACRONIX, 0x20, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT}, \
+ /* MX25L51245G */ \
+ {SFUD_MF_ID_MACRONIX, 0x20, 0x1A, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
/* GD25Q64B */ \
{SFUD_MF_ID_GIGADEVICE, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT}, \
}
diff --git a/components/drivers/spi/spi_msd.c b/components/drivers/spi/spi_msd.c
index a109fd9488..191933e421 100644
--- a/components/drivers/spi/spi_msd.c
+++ b/components/drivers/spi/spi_msd.c
@@ -234,24 +234,30 @@ static rt_err_t _send_cmd(
else if (type == response_r2)
{
/* initial message */
+ /* Prevent non-aligned address access, use recv_buffer to receive data */
message.send_buf = RT_NULL;
- message.recv_buf = response + 1;
+ message.recv_buf = recv_buffer;
message.length = 1;
message.cs_take = message.cs_release = 0;
/* transfer message */
device->bus->ops->xfer(device, &message);
+ response[1] = recv_buffer[0];
}
else if ((type == response_r3) || (type == response_r7))
{
/* initial message */
message.send_buf = RT_NULL;
- message.recv_buf = response + 1;
+ message.recv_buf = recv_buffer;
message.length = 4;
message.cs_take = message.cs_release = 0;
/* transfer message */
device->bus->ops->xfer(device, &message);
+ response[1] = recv_buffer[0];
+ response[2] = recv_buffer[1];
+ response[3] = recv_buffer[2];
+ response[4] = recv_buffer[3];
}
else
{
diff --git a/components/drivers/src/dataqueue.c b/components/drivers/src/dataqueue.c
index 5a802c0711..ba4a921da0 100644
--- a/components/drivers/src/dataqueue.c
+++ b/components/drivers/src/dataqueue.c
@@ -28,6 +28,7 @@ rt_data_queue_init(struct rt_data_queue *queue,
void (*evt_notify)(struct rt_data_queue *queue, rt_uint32_t event))
{
RT_ASSERT(queue != RT_NULL);
+ RT_ASSERT((0x10000 % size) == 0);
queue->evt_notify = evt_notify;
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index c4fc3b0ad9..64230533ae 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -589,8 +589,9 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
/* create a cdc function */
func = rt_usbd_function_new(device, &dev_desc, &ops);
- //not support HS
- //rt_usbd_device_set_qualifier(device, &dev_qualifier);
+
+ /* support HS */
+ rt_usbd_device_set_qualifier(device, &dev_qualifier);
/* allocate memory for cdc vcom data */
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c
index 5df63daddf..a4acce75ea 100644
--- a/components/drivers/usb/usbdevice/class/hid.c
+++ b/components/drivers/usb/usbdevice/class/hid.c
@@ -29,7 +29,7 @@ struct hid_s
uep_t ep_in;
uep_t ep_out;
int status;
- rt_uint16_t protocol;
+ rt_uint8_t protocol;
rt_uint8_t report_buf[MAX_REPORT_SIZE];
struct rt_messagequeue hid_mq;
};
@@ -246,7 +246,7 @@ static struct udevice_descriptor _dev_desc =
USB_DESC_LENGTH_DEVICE, //bLength;
USB_DESC_TYPE_DEVICE, //type;
USB_BCD_VERSION, //bcdUSB;
- USB_CLASS_HID, //bDeviceClass;
+ 0x0, //bDeviceClass;
0x00, //bDeviceSubClass;
0x00, //bDeviceProtocol;
64, //bMaxPacketSize0;
@@ -266,8 +266,8 @@ static struct usb_qualifier_descriptor dev_qualifier =
sizeof(dev_qualifier), //bLength
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
0x0200, //bcdUSB
- USB_CLASS_MASS_STORAGE, //bDeviceClass
- 0x06, //bDeviceSubClass
+ 0x0, //bDeviceClass
+ 0x0, //bDeviceSubClass
0x50, //bDeviceProtocol
64, //bMaxPacketSize0
0x01, //bNumConfigurations
@@ -347,7 +347,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
USB_DYNAMIC | USB_DIR_IN,
USB_EP_ATTR_INT,
0x40,
- 0x01,
+ 0x0A,
},
/* Endpoint Descriptor OUT */
@@ -458,6 +458,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
struct hid_s *data = (struct hid_s *) func->user_data;
+
switch (setup->bRequest)
{
case USB_REQ_GET_DESCRIPTOR:
@@ -486,7 +487,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
dcd_ep0_send_status(func->device->dcd);
break;
case USB_HID_REQ_GET_PROTOCOL:
- rt_usbd_ep0_write(func->device, &data->protocol,2);
+ rt_usbd_ep0_write(func->device, &data->protocol,1);
break;
case USB_HID_REQ_SET_REPORT:
@@ -692,8 +693,9 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
/* create a cdc function */
func = rt_usbd_function_new(device, &_dev_desc, &ops);
- //not support hs
- //rt_usbd_device_set_qualifier(device, &_dev_qualifier);
+
+ /* For high speed mode supporting */
+ rt_usbd_device_set_qualifier(device, &dev_qualifier);
/* allocate memory for cdc vcom data */
data = (struct hid_s*)rt_malloc(sizeof(struct hid_s));
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c
index a681b8212f..d0a2b7f736 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.c
+++ b/components/drivers/usb/usbdevice/class/mstorage.c
@@ -610,8 +610,11 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
rt_usbd_ep_set_stall(func->device, data->ep_out);
}
else
- {
- rt_usbd_ep_set_stall(func->device, data->ep_in);
+ {
+ //rt_kprintf("warning:in stall path but not stall\n");
+
+ /* FIXME: Disable the operation or the disk cannot work. */
+ //rt_usbd_ep_set_stall(func->device, data->ep_in);
}
data->csw_response.data_reside = 0;
}
@@ -719,9 +722,22 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
break;
}
}
+
+ //workaround: for stability in full-speed mode
+ else if(cmd->cmd_len == 12)
+ {
+ switch(cmd->type)
+ {
+ case COUNT:
+ data->cb_data_size = cbw->cb[4];
+ break;
+ default:
+ break;
+ }
+ }
else
{
-// rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
+ rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
}
}
@@ -737,7 +753,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
data = (struct mstorage*)func->user_data;
if(cmd->cmd_len != cbw->cb_len)
{
- // rt_kprintf("cb_len error\n");
+ rt_kprintf("cb_len error\n");
cmd->cmd_len = cbw->cb_len;
}
@@ -768,7 +784,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
if(cbw->xfer_len < data->cb_data_size)
{
- // rt_kprintf("xfer_len < data_size\n");
+ rt_kprintf("xfer_len < data_size\n");
data->cb_data_size = cbw->xfer_len;
data->csw_response.status = 1;
}
diff --git a/components/drivers/usb/usbhost/core/usbhost_core.c b/components/drivers/usb/usbhost/core/usbhost_core.c
index 71341a33c3..d72dca82f2 100644
--- a/components/drivers/usb/usbhost/core/usbhost_core.c
+++ b/components/drivers/usb/usbhost/core/usbhost_core.c
@@ -162,6 +162,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
/* alloc memory for configuration descriptor */
device->cfg_desc = (ucfg_desc_t)rt_malloc(cfg_desc.wTotalLength);
+ if(device->cfg_desc == RT_NULL)
+ {
+ return RT_ENOMEM;
+ }
rt_memset(device->cfg_desc, 0, cfg_desc.wTotalLength);
/* get full configuration descriptor */
@@ -219,6 +223,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
{
/* allocate memory for interface device */
device->intf[i] = (struct uhintf*)rt_malloc(sizeof(struct uhintf));
+ if(device->intf[i] == RT_NULL)
+ {
+ return RT_ENOMEM;
+ }
device->intf[i]->drv = drv;
device->intf[i]->device = device;
device->intf[i]->intf_desc = intf_desc;
diff --git a/components/libc/Kconfig b/components/libc/Kconfig
index 26e156522b..65c8d44225 100644
--- a/components/libc/Kconfig
+++ b/components/libc/Kconfig
@@ -22,11 +22,15 @@ if RT_USING_LIBC && RT_USING_DFS
if RT_USING_POSIX
config RT_USING_POSIX_MMAP
- bool "Enable mmap() api"
+ bool "Enable mmap() API"
default n
config RT_USING_POSIX_TERMIOS
- bool "Enable termios feature"
+ bool "Enable termios APIs"
+ default n
+
+ config RT_USING_POSIX_GETLINE
+ bool "Enable getline()/getdelim() APIs"
default n
config RT_USING_POSIX_AIO
diff --git a/components/libc/compilers/armlibc/fcntl.h b/components/libc/compilers/armlibc/fcntl.h
index 80cf1b4409..3e650a8471 100644
--- a/components/libc/compilers/armlibc/fcntl.h
+++ b/components/libc/compilers/armlibc/fcntl.h
@@ -9,6 +9,8 @@
#ifndef FCNTL_H__
#define FCNTL_H__
+#include <rtconfig.h>
+
#ifdef RT_USING_DFS
#include <dfs_posix.h>
#endif
diff --git a/components/libc/compilers/dlib/termios.h b/components/libc/compilers/armlibc/sys/ioctl.h
index 1956121225..033a57014a 100644
--- a/components/libc/compilers/dlib/termios.h
+++ b/components/libc/compilers/armlibc/sys/ioctl.h
@@ -5,11 +5,11 @@
*
* Change Logs:
* Date Author Notes
+ * 2020-09-01 Meco Man First Version
*/
-#ifndef _TERMIOS_H__
-#define _TERMIOS_H__
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+
-#include <sys/types.h>
-#include <posix_termios.h>
#endif
diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h
index 001ace4dd2..2aad77c99d 100644
--- a/components/libc/compilers/armlibc/sys/types.h
+++ b/components/libc/compilers/armlibc/sys/types.h
@@ -5,16 +5,16 @@
*
* Change Logs:
* Date Author Notes
+ * 2020-09-05 Meco Man fix bugs
*/
#ifndef __TYPES_H__
#define __TYPES_H__
#include <stdint.h>
-#include <rtthread.h>
-typedef rt_int32_t clockid_t;
-typedef rt_int32_t key_t; /* Used for interprocess communication. */
-typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */
+typedef int32_t clockid_t;
+typedef int32_t key_t; /* Used for interprocess communication. */
+typedef int32_t pid_t; /* Used for process IDs and process group IDs. */
#ifndef ARCH_CPU_64BIT
typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */
#else
diff --git a/components/libc/compilers/armlibc/sys/unistd.h b/components/libc/compilers/armlibc/sys/unistd.h
index 33f0561e72..3199b01e0e 100644
--- a/components/libc/compilers/armlibc/sys/unistd.h
+++ b/components/libc/compilers/armlibc/sys/unistd.h
@@ -46,4 +46,8 @@
#define O_SYNC _FSYNC
#endif
+
+int isatty (int fd);
+char * ttyname (int desc);
+
#endif /* _SYS_UNISTD_H */
diff --git a/components/libc/compilers/armlibc/unistd.h b/components/libc/compilers/armlibc/unistd.h
index 70187722d8..736fc219a8 100644
--- a/components/libc/compilers/armlibc/unistd.h
+++ b/components/libc/compilers/armlibc/unistd.h
@@ -7,3 +7,4 @@
* Date Author Notes
*/
#include "sys/unistd.h"
+
diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript
index a8d2606820..2407301405 100644
--- a/components/libc/compilers/common/SConscript
+++ b/components/libc/compilers/common/SConscript
@@ -8,12 +8,15 @@ group = []
CPPPATH = [cwd]
if GetDepend('RT_USING_LIBC'):
- src += Glob('*.c')
+ src += Glob('*.c')
else:
- if GetDepend('RT_LIBC_USING_TIME'):
+ if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'):
src += ['time.c']
-if (rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'iar') and rtconfig.ARCH != 'sim' :
- group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH)
+if GetDepend('RT_USING_POSIX') == False:
+ SrcRemove(src, ['unistd.c'])
+
+if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')):
+ group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md
new file mode 100644
index 0000000000..cb91d95f45
--- /dev/null
+++ b/components/libc/compilers/common/readme.md
@@ -0,0 +1 @@
+This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc. \ No newline at end of file
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 1d68eeafa3..22f1c17f5e 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -5,6 +5,7 @@
*
* Change Logs:
* Date Author Notes
+ * 2020-09-07 Meco Man combine gcc armcc iccarm
*/
#ifndef _SYS_TIME_H_
#define _SYS_TIME_H_
@@ -15,6 +16,14 @@
extern "C" {
#endif
+/*
+ * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001.
+ */
+#if defined ( __ICCARM__ ) && (__VER__ >= 8010001)
+#define _TIMESPEC_DEFINED
+#endif
+
+
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
/*
@@ -27,23 +36,6 @@ struct timeval {
};
#endif /* _TIMEVAL_DEFINED */
-/*
- * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001.
- */
-#if defined ( __ICCARM__ ) && (__VER__ >= 8010001)
-#define _TIMESPEC_DEFINED
-#endif
-
-#ifndef _TIMESPEC_DEFINED
-#define _TIMESPEC_DEFINED
-/*
- * Structure defined by POSIX.1b to be like a timeval.
- */
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
-#endif /* _TIMESPEC_DEFINED */
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
diff --git a/components/libc/compilers/armlibc/termios.h b/components/libc/compilers/common/termios.h
index 1956121225..ee2b4d5718 100644
--- a/components/libc/compilers/armlibc/termios.h
+++ b/components/libc/compilers/common/termios.h
@@ -9,7 +9,9 @@
#ifndef _TERMIOS_H__
#define _TERMIOS_H__
+#ifdef RT_USING_POSIX_TERMIOS
#include <sys/types.h>
#include <posix_termios.h>
+#endif
#endif
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 50a800b259..99dab71eb4 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2019-08-21 zhangjun copy from minilibc
+ * 2020-09-07 Meco Man combine gcc armcc iccarm
*/
#include <sys/time.h>
diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c
new file mode 100644
index 0000000000..4068fc5cf5
--- /dev/null
+++ b/components/libc/compilers/common/unistd.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-09-01 Meco Man First Version
+ */
+
+#include <unistd.h>
+
+#ifdef RT_USING_POSIX_TERMIOS
+#include <termios.h>
+
+int isatty(int fd)
+{
+ struct termios ts;
+ return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/
+}
+#endif
+
+char *ttyname(int fd)
+{
+ return "/dev/tty0"; /*TODO: need to add more specific*/
+}
diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h
index 29f68f24f8..9564daba8d 100644
--- a/components/libc/compilers/dlib/sys/unistd.h
+++ b/components/libc/compilers/dlib/sys/unistd.h
@@ -36,4 +36,8 @@
#endif
+
+int isatty (int fd);
+char * ttyname (int desc);
+
#endif /* _SYS_UNISTD_H */
diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript
index 518d800571..dec657028f 100644
--- a/components/libc/compilers/minilibc/SConscript
+++ b/components/libc/compilers/minilibc/SConscript
@@ -8,7 +8,7 @@ group = []
CPPPATH = [cwd]
CPPDEFINES = ['RT_USING_MINILIBC']
-if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC'):
+if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_MINILIBC'):
group = DefineGroup('libc', src, depend = [''],
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
diff --git a/components/libc/compilers/newlib/termios.h b/components/libc/compilers/newlib/termios.h
deleted file mode 100644
index 1956121225..0000000000
--- a/components/libc/compilers/newlib/termios.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- */
-#ifndef _TERMIOS_H__
-#define _TERMIOS_H__
-
-#include <sys/types.h>
-#include <posix_termios.h>
-
-#endif
diff --git a/components/libc/compilers/newlib/time.c b/components/libc/compilers/newlib/time.c
deleted file mode 100644
index f099d51330..0000000000
--- a/components/libc/compilers/newlib/time.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- */
-#include <sys/time.h>
-#include <rtthread.h>
-
-#ifdef RT_USING_DEVICE
-int gettimeofday(struct timeval *tp, void *ignore)
-{
- time_t time;
- rt_device_t device;
-
- device = rt_device_find("rtc");
- RT_ASSERT(device != RT_NULL);
-
- rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
- if (tp != RT_NULL)
- {
- tp->tv_sec = time;
- tp->tv_usec = 0;
- }
-
- return time;
-}
-#endif
-
-/**
- * Returns the current time.
- *
- * @param time_t * t the timestamp pointer, if not used, keep NULL.
- *
- * @return time_t return timestamp current.
- *
- */
-/* for IAR 6.2 later Compiler */
-#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000
-#pragma module_name = "?time"
-time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */
-#else
-time_t time(time_t *t)
-#endif
-{
- time_t time_now = 0;
-
-#ifdef RT_USING_RTC
- static rt_device_t device = RT_NULL;
-
- /* optimization: find rtc device only first. */
- if (device == RT_NULL)
- {
- device = rt_device_find("rtc");
- }
-
- /* read timestamp from RTC device. */
- if (device != RT_NULL)
- {
- if (rt_device_open(device, 0) == RT_EOK)
- {
- rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now);
- rt_device_close(device);
- }
- }
-#endif /* RT_USING_RTC */
-
- /* if t is not NULL, write timestamp to *t */
- if (t != RT_NULL)
- {
- *t = time_now;
- }
-
- return time_now;
-}
-
-RT_WEAK clock_t clock(void)
-{
- return rt_tick_get();
-}
diff --git a/components/libc/getline/README.md b/components/libc/getline/README.md
new file mode 100644
index 0000000000..3ba5a96b3d
--- /dev/null
+++ b/components/libc/getline/README.md
@@ -0,0 +1,30 @@
+# getline/getdelim for RT-Thread POSIX(IEEE Std 1003.1-2008)
+
+[![Build Status](https://travis-ci.org/ivanrad/getline.svg?branch=master)](https://travis-ci.org/ivanrad/getline)
+
+https://github.com/ivanrad/getline
+
+Read a delimited record from stream.
+
+Yet another (hopefully portable C) implementation of getline/getdelim.
+These are ersatz functions, a drop-in replacement, to be used on those occasions when your C library does not already support them.
+
+For more details, see [Open Group Base Specification for getdelim/getline][opengroup-spec].
+
+## Building the project
+
+Just run `make`.
+
+## License
+
+This code is unlicensed -- free and released into the public domain. See `UNLICENSE` file for more information.
+
+[opengroup-spec]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html
+
+
+## 联系&维护
+Meco Man
+
+
+https://github.com/mysterywolf/getline
diff --git a/components/libc/getline/SConscript b/components/libc/getline/SConscript
new file mode 100644
index 0000000000..fa4c8618c1
--- /dev/null
+++ b/components/libc/getline/SConscript
@@ -0,0 +1,13 @@
+# RT-Thread building script for component
+
+from building import *
+
+cwd = GetCurrentDir()
+src = Glob('*.c') + Glob('*.cpp')
+CPPPATH = [cwd]
+
+group = DefineGroup('libc', src,
+ depend = ['RT_USING_LIBC', 'RT_USING_POSIX','RT_USING_POSIX_GETLINE'],
+ CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/libc/getline/UNLICENSE b/components/libc/getline/UNLICENSE
new file mode 100644
index 0000000000..68a49daad8
--- /dev/null
+++ b/components/libc/getline/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/components/libc/getline/posix_getline.c b/components/libc/getline/posix_getline.c
new file mode 100644
index 0000000000..2c60ca7647
--- /dev/null
+++ b/components/libc/getline/posix_getline.c
@@ -0,0 +1,79 @@
+/* posix_getline.c
+ * RT-Thread POSIX
+ * getdelim(), getline() - read a delimited record from stream, ersatz implementation
+ * This code is unlicensed -- free and released into the public domain.
+ * https://man7.org/linux/man-pages/man3/getline.3.html
+ * Authors:
+ * https://github.com/ivanrad/getline
+ * https://github.com/mysterywolf/getline/
+ *
+ * Meco Man 2020-09-03 First Version
+ */
+
+#include <posix_getline.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <rtlibc.h>
+
+ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) {
+ char *cur_pos, *new_lineptr;
+ size_t new_lineptr_len;
+ int c;
+
+ if (lineptr == NULL || n == NULL || stream == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (*lineptr == NULL) {
+ *n = 128; /* init len */
+ if ((*lineptr = (char *)malloc(*n)) == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+
+ cur_pos = *lineptr;
+ for (;;) {
+ c = getc(stream);
+
+ if (ferror(stream) || (c == EOF && cur_pos == *lineptr))
+ return -1;
+
+ if (c == EOF)
+ break;
+
+ if ((*lineptr + *n - cur_pos) < 2) {
+ if (SSIZE_MAX / 2 < *n) {
+#ifdef EOVERFLOW
+ errno = EOVERFLOW;
+#else
+ errno = ERANGE; /* no EOVERFLOW defined */
+#endif
+ return -1;
+ }
+ new_lineptr_len = *n * 2;
+
+ if ((new_lineptr = (char *)realloc(*lineptr, new_lineptr_len)) == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ cur_pos = new_lineptr + (cur_pos - *lineptr);
+ *lineptr = new_lineptr;
+ *n = new_lineptr_len;
+ }
+
+ *cur_pos++ = (char)c;
+
+ if (c == delim)
+ break;
+ }
+
+ *cur_pos = '\0';
+ return (ssize_t)(cur_pos - *lineptr);
+}
+
+ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
+ return getdelim(lineptr, n, '\n', stream);
+}
+
diff --git a/components/libc/getline/posix_getline.h b/components/libc/getline/posix_getline.h
new file mode 100644
index 0000000000..c7d6021af3
--- /dev/null
+++ b/components/libc/getline/posix_getline.h
@@ -0,0 +1,24 @@
+/* posix_getline.h
+ * RT-Thread POSIX
+ * getdelim(), getline() - read a delimited record from stream, ersatz implementation
+ * This code is unlicensed -- free and released into the public domain.
+ * https://man7.org/linux/man-pages/man3/getline.3.html
+ * Authors:
+ * https://github.com/ivanrad/getline
+ * https://github.com/mysterywolf/getline/
+ *
+ * Meco Man 2020-09-03 First Version
+ */
+
+
+#ifndef POSIX_GETLINE_H
+#define POSIX_GETLINE_H
+
+#include <stdio.h>
+#include <sys/types.h>
+
+ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
+ssize_t getline(char **lineptr, size_t *n, FILE *stream);
+
+#endif /* POSIX_GETLINE_H */
+
diff --git a/components/libc/termios/posix_termios.c b/components/libc/termios/posix_termios.c
index 75c876dd33..9c736c3184 100644
--- a/components/libc/termios/posix_termios.c
+++ b/components/libc/termios/posix_termios.c
@@ -5,7 +5,7 @@
*
* Change Logs:
* Date Author Notes
- * 2017/08/30 Bernard The first version
+ * 2017/08/30 Bernard The first version
*/
#include <stdlib.h>
#include <string.h>
@@ -111,13 +111,6 @@ int tcdrain(int fd)
return 0;
}
-int isatty (int fd)
-{
- struct termios term;
-
- return tcgetattr (fd, &term) == 0;
-}
-
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
void cfmakeraw(struct termios *t)
{
diff --git a/components/libc/termios/posix_termios.h b/components/libc/termios/posix_termios.h
index 6d4be129ff..c61191b7dc 100644
--- a/components/libc/termios/posix_termios.h
+++ b/components/libc/termios/posix_termios.h
@@ -5,13 +5,13 @@
*
* Change Logs:
* Date Author Notes
- * 2017/08/30 Bernard The first version
+ * 2017/08/30 Bernard The first version
*/
#ifndef TERMIOS_H__
#define TERMIOS_H__
#include <rtthread.h>
-#include <termios.h>
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/components/net/Kconfig b/components/net/Kconfig
index 45bc8d101c..3a4f39ed49 100644
--- a/components/net/Kconfig
+++ b/components/net/Kconfig
@@ -118,7 +118,7 @@ config RT_USING_LWIP
config RT_USING_LWIP202
bool "lwIP v2.0.2"
- config RT_USING_LWIP212
+ config RT_USING_LWIP212
bool "lwIP v2.1.2"
endchoice
@@ -131,6 +131,10 @@ config RT_USING_LWIP
select NETDEV_IPV6_SCOPES if RT_USING_LWIP212
endif
+ config RT_LWIP_MEM_ALIGNMENT
+ int "Memory alignment"
+ default 4
+
config RT_LWIP_IGMP
bool "IGMP protocol"
default y
diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h
index 5304091755..604477dab8 100644
--- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h
+++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h
@@ -66,7 +66,7 @@ typedef uintptr_t mem_ptr_t;
#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */
#endif
-#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME)
+#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__)
#include <sys/time.h>
#define LWIP_TIMEVAL_PRIVATE 0
#else
diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
index 491cab6b5f..00536a8419 100644
--- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
+++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
@@ -45,7 +45,7 @@
#define S32_F "ld"
#define X32_F "lx"
-#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME)
+#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__)
#include <sys/time.h>
#define LWIP_TIMEVAL_PRIVATE 0
#else
diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c
index f7ed6eedec..40c79011ec 100644
--- a/components/net/lwip-2.0.2/src/arch/sys_arch.c
+++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c
@@ -460,7 +460,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{
RT_DEBUG_NOT_IN_INTERRUPT;
- rt_mb_send_wait(*mbox, (rt_uint32_t)msg, RT_WAITING_FOREVER);
+ rt_mb_send_wait(*mbox, (rt_ubase_t)msg, RT_WAITING_FOREVER);
return;
}
@@ -472,7 +472,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg)
*/
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
- if (rt_mb_send(*mbox, (rt_uint32_t)msg) == RT_EOK)
+ if (rt_mb_send(*mbox, (rt_ubase_t)msg) == RT_EOK)
return ERR_OK;
return ERR_MEM;
diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h
index c53863e1ab..09bd223aa4 100644
--- a/components/net/lwip-2.0.2/src/lwipopts.h
+++ b/components/net/lwip-2.0.2/src/lwipopts.h
@@ -230,7 +230,12 @@
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- Memory options ---------- */
+#ifdef RT_LWIP_MEM_ALIGNMENT
+#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT
+#else
#define MEM_ALIGNMENT 4
+#endif
+
#define MEMP_OVERFLOW_CHECK 1 ////
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 ////
//#define MEM_LIBC_MALLOC 1
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 2fa528aa0d..b93acb1fcf 100644
--- a/components/net/lwip-2.0.2/src/netif/ethernetif.c
+++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c
@@ -38,6 +38,7 @@
* after lwIP initialization.
* 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant.
* 2016-08-18 Bernard port to lwIP 2.0.0
+ * 2020-08-10 lizhirui fixed some problems when this is running on 64-bit cpu
*/
#include "lwip/opt.h"
@@ -85,10 +86,10 @@ struct eth_tx_msg
static struct rt_mailbox eth_tx_thread_mb;
static struct rt_thread eth_tx_thread;
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
-static char eth_tx_thread_mb_pool[32 * 4];
+static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[512];
#else
-static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
+static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif
#endif
@@ -97,10 +98,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
static struct rt_mailbox eth_rx_thread_mb;
static struct rt_thread eth_rx_thread;
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
-static char eth_rx_thread_mb_pool[48 * 4];
+static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[1024];
#else
-static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
+static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif
#endif
@@ -395,7 +396,7 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p)
/* send a message to eth tx thread */
msg.netif = netif;
msg.buf = p;
- if (rt_mb_send(&eth_tx_thread_mb, (rt_uint32_t) &msg) == RT_EOK)
+ if (rt_mb_send(&eth_tx_thread_mb, (rt_ubase_t) &msg) == RT_EOK)
{
/* waiting for ack */
rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER);
@@ -599,7 +600,7 @@ rt_err_t eth_device_ready(struct eth_device* dev)
{
if (dev->netif)
/* post message to Ethernet thread */
- return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
+ return rt_mb_send(&eth_rx_thread_mb, (rt_ubase_t)dev);
else
return ERR_OK; /* netif is not initialized yet, just return. */
}
@@ -619,7 +620,7 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
rt_hw_interrupt_enable(level);
/* post message to ethernet thread */
- return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev);
+ return rt_mb_send(&eth_rx_thread_mb, (rt_ubase_t)dev);
}
#else
/* NOTE: please not use it in interrupt when no RxThread exist */
@@ -739,7 +740,7 @@ int eth_system_device_init_private(void)
#ifndef LWIP_NO_RX_THREAD
/* initialize mailbox and create Ethernet Rx thread */
result = rt_mb_init(&eth_rx_thread_mb, "erxmb",
- &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4,
+ &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK);
@@ -755,7 +756,7 @@ int eth_system_device_init_private(void)
#ifndef LWIP_NO_TX_THREAD
/* initialize mailbox and create Ethernet Tx thread */
result = rt_mb_init(&eth_tx_thread_mb, "etxmb",
- &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4,
+ &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK);
diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h
index c1b4cf7d29..6905ecd442 100644
--- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h
+++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h
@@ -59,7 +59,7 @@
#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */
#endif /* RT_USING_LIBC */
-#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME)
+#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__)
#include <sys/time.h>
#define LWIP_TIMEVAL_PRIVATE 0
#else
diff --git a/components/net/uip/rt-thread/uip_ethernetif.c b/components/net/uip/rt-thread/uip_ethernetif.c
index fa4e52461e..4fef184f4a 100644
--- a/components/net/uip/rt-thread/uip_ethernetif.c
+++ b/components/net/uip/rt-thread/uip_ethernetif.c
@@ -63,11 +63,11 @@ static struct rt_mailbox eth_rx_thread_mb;
static struct rt_thread eth_rx_thread;
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
#define RT_ETHERNETIF_THREAD_PREORITY 0x90
-static char eth_rx_thread_mb_pool[48 * 4];
+static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[1024];
#else
#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY
-static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
+static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif
@@ -79,10 +79,10 @@ struct eth_tx_msg
static struct rt_mailbox eth_tx_thread_mb;
static struct rt_thread eth_tx_thread;
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
-static char eth_tx_thread_mb_pool[32 * 4];
+static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[512];
#else
-static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
+static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif
@@ -281,7 +281,7 @@ rt_err_t eth_system_device_init()
/* init rx thread */
/* init mailbox and create ethernet thread */
result = rt_mb_init(&eth_rx_thread_mb, "erxmb",
- &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4,
+ &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK);
@@ -297,7 +297,7 @@ rt_err_t eth_system_device_init()
/* init mailbox and create ethernet thread */
result = rt_mb_init(&eth_tx_thread_mb, "etxmb",
- &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4,
+ &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK);
diff --git a/components/utilities/ulog/syslog/syslog.c b/components/utilities/ulog/syslog/syslog.c
index 872c84d331..4c290bed52 100644
--- a/components/utilities/ulog/syslog/syslog.c
+++ b/components/utilities/ulog/syslog/syslog.c
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include <ulog.h>
#include <rthw.h>
+#include <stdint.h>
#include "syslog.h"
#ifdef ULOG_OUTPUT_FLOAT
diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h
index 2c91bfe0e1..8d83fa3184 100644
--- a/components/utilities/utest/utest.h
+++ b/components/utilities/utest/utest.h
@@ -12,6 +12,7 @@
#define __UTEST_H__
#include <rtthread.h>
+#include <stdint.h>
#include "utest_log.h"
#include "utest_assert.h"