Skip to content

Commit 9d846d9

Browse files
committed
Merge pull request #31 from adamgreen/gccWarnFixNetwork
Update LPC1768 linker script and silence GNU warnings in network stack
2 parents 092da0d + 282c354 commit 9d846d9

File tree

7 files changed

+40
-16
lines changed

7 files changed

+40
-16
lines changed

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_ARM/LPC1768.ld

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MEMORY
55
{
66
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
7-
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38
7+
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
88

99
USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
1010
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
@@ -84,6 +84,7 @@ SECTIONS
8484
.data : AT (__etext)
8585
{
8686
__data_start__ = .;
87+
Image$$RW_IRAM1$$Base = .;
8788
*(vtable)
8889
*(.data*)
8990

@@ -120,6 +121,7 @@ SECTIONS
120121
*(.bss*)
121122
*(COMMON)
122123
__bss_end__ = .;
124+
Image$$RW_IRAM1$$ZI$$Limit = . ;
123125
} > RAM
124126

125127
.heap :
@@ -146,4 +148,23 @@ SECTIONS
146148

147149
/* Check if data + heap + stack exceeds RAM limit */
148150
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151+
152+
153+
/* Code can explicitly ask for data to be
154+
placed in these higher RAM banks where
155+
they will be left uninitialized.
156+
*/
157+
.AHBSRAM0 (NOLOAD):
158+
{
159+
Image$$RW_IRAM2$$Base = . ;
160+
*(AHBSRAM0)
161+
Image$$RW_IRAM2$$ZI$$Limit = .;
162+
} > USB_RAM
163+
164+
.AHBSRAM1 (NOLOAD):
165+
{
166+
Image$$RW_IRAM3$$Base = . ;
167+
*(AHBSRAM1)
168+
Image$$RW_IRAM3$$ZI$$Limit = .;
169+
} > ETH_RAM
149170
}

libraries/net/eth/lwip-eth/arch/lpc17_emac.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,14 @@ static err_t lpc_low_level_output(struct netif *netif, struct pbuf *p)
618618
struct lpc_enetdata *lpc_enetif = netif->state;
619619
struct pbuf *q;
620620
u8_t *dst;
621-
u32_t idx;
621+
u32_t idx, notdmasafe = 0;
622622
struct pbuf *np;
623-
u32_t dn, notdmasafe = 0;
623+
s32_t dn;
624624

625625
/* Zero-copy TX buffers may be fragmented across mutliple payload
626626
chains. Determine the number of descriptors needed for the
627627
transfer. The pbuf chaining can be a mess! */
628-
dn = (u32_t) pbuf_clen(p);
628+
dn = (s32_t) pbuf_clen(p);
629629

630630
/* Test to make sure packet addresses are DMA safe. A DMA safe
631631
address is once that uses external memory or periphheral RAM.

libraries/net/eth/lwip-eth/arch/lpc_phy_dp83848.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ err_t lpc_phy_init(struct netif *netif, int rmii)
228228
u32_t tmp;
229229
s32_t i;
230230

231-
physts.phy_speed_100mbs = olddphysts.phy_speed_100mbs = 2;
232-
physts.phy_full_duplex = olddphysts.phy_full_duplex = 2;
233-
physts.phy_link_active = olddphysts.phy_link_active = 2;
231+
physts.phy_speed_100mbs = olddphysts.phy_speed_100mbs = 0;
232+
physts.phy_full_duplex = olddphysts.phy_full_duplex = 0;
233+
physts.phy_link_active = olddphysts.phy_link_active = 0;
234234
phyustate = 0;
235235

236236
/* Only first read and write are checked for failure */

libraries/net/lwip/Socket/TCPSocketConnection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int TCPSocketConnection::send_all(char* data, int length) {
6666
if ((_sock_fd < 0) || !_is_connected)
6767
return -1;
6868

69-
size_t writtenLen = 0;
69+
int writtenLen = 0;
7070
TimeInterval timeout(_timeout);
7171
while (writtenLen < length) {
7272
if (!_blocking) {
@@ -110,7 +110,7 @@ int TCPSocketConnection::receive_all(char* data, int length) {
110110
if ((_sock_fd < 0) || !_is_connected)
111111
return -1;
112112

113-
size_t readLen = 0;
113+
int readLen = 0;
114114
TimeInterval timeout(_timeout);
115115
while (readLen < length) {
116116
if (!_blocking) {

libraries/net/lwip/lwip-sys/arch/cc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ typedef uintptr_t mem_ptr_t;
8080
#define PACK_STRUCT_END
8181
#define PACK_STRUCT_FIELD(fld) fld
8282
#define ALIGNED(n) __attribute__((aligned (n)))
83-
#define ALIGNED(n) __align(n)
8483
#endif
8584

8685
/* Used with IP headers only */

libraries/net/lwip/lwip/core/dhcp.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ dhcp_handle_ack(struct netif *netif)
564564
#if LWIP_DNS
565565
/* DNS servers */
566566
n = 0;
567-
while(dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n) && (n < DNS_MAX_SERVERS)) {
567+
while((n < DNS_MAX_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)) {
568568
ip_addr_t dns_addr;
569569
ip4_addr_set_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)));
570570
dns_setserver(n, &dns_addr);
@@ -975,7 +975,7 @@ dhcp_bind(struct netif *netif)
975975

976976
ip_addr_copy(gw_addr, dhcp->offered_gw_addr);
977977
/* gateway address not given? */
978-
if (ip_addr_isany(&gw_addr)) {
978+
if (gw_addr.addr == IPADDR_ANY) {
979979
/* copy network address */
980980
ip_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask);
981981
/* use first host address on network as gateway */
@@ -1678,9 +1678,13 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type)
16781678
ip_addr_set_zero(&dhcp->msg_out->yiaddr);
16791679
ip_addr_set_zero(&dhcp->msg_out->siaddr);
16801680
ip_addr_set_zero(&dhcp->msg_out->giaddr);
1681-
for (i = 0; i < DHCP_CHADDR_LEN; i++) {
1682-
/* copy netif hardware address, pad with zeroes */
1683-
dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/;
1681+
for (i = 0; i < netif->hwaddr_len; i++) {
1682+
/* copy netif hardware address */
1683+
dhcp->msg_out->chaddr[i] = netif->hwaddr[i];
1684+
}
1685+
for ( ; i < DHCP_CHADDR_LEN; i++) {
1686+
/* ... pad rest with zeroes */
1687+
dhcp->msg_out->chaddr[i] = 0;
16841688
}
16851689
for (i = 0; i < DHCP_SNAME_LEN; i++) {
16861690
dhcp->msg_out->sname[i] = 0;

libraries/net/lwip/lwip/core/ipv4/ip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ ip_input(struct pbuf *p, struct netif *inp)
400400
/* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */
401401
#if IP_ACCEPT_LINK_LAYER_ADDRESSING
402402
/* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */
403-
if (check_ip_src && !ip_addr_isany(&current_iphdr_src))
403+
if (check_ip_src && current_iphdr_src.addr != IPADDR_ANY)
404404
#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
405405
{ if ((ip_addr_isbroadcast(&current_iphdr_src, inp)) ||
406406
(ip_addr_ismulticast(&current_iphdr_src))) {

0 commit comments

Comments
 (0)