As you know I was facing some issues to get PPPD connection working:
https://acassis.wordpress.com/2019/02/10/debugging-pppd-using-quectel-m95-on-samd21-board/
Then I received a comment from Vladimir Novikov (thank you!) at that post commenting the issues was introduced some time ago at this commit:
https://bitbucket.org/nuttx/apps/commits/cddfda99f0a519681b894b7a12560406c4372cfb
And he suggested me adding this line to lcp.c:
tptr = bptr; + bptr += 4; error = 0;
Before testing this suggestion I received an email from Quectel Brasil support (thanks Micael Lisboa) suggesting run this AT cmd:
AT+QACCM=0,0
Micael’s suggestion worked fine.
But I decided to contact the author of the modification (Xiao Xiang) and he explained that the bptr was already increased by 4 compared to original code. And in fact he was correct.
Anyway I decided to test Vladimir’s suggestion that also worked. So we need to investigate it in more details to understand what is happening.
BTW since the AT command was working for me I decided to follow with my tests.
After PPPD connection was established it was getting IP:
nsh> ifconfig ppp0 Link encap:TUN at UP inet addr:100.75.210.38 DRaddr:192.168.254.254 Mask:0.0.0.0
But ping command was crashing:
nsh> ping 8.8.8.8 PINGup_assert: Assertion failed at file:armv6-m/up_hardfault.c line: 139 up_registerdump: R0: 20000a78 00000000 00000000 00004a64 20000819 20006f8c 20000a78 00000000 up_registerdump: R8: 00000000 00000000 00000000 00000000 20000414 20003fa0 0000b54f 00009dd6 up_registerdump: xPSR: 21000000 PRIMASK: 00000000 up_dumpstate: sp: 20003ee8 up_dumpstate: stack base: 20004040 up_dumpstate: stack size: 000007e4 up_stackdump: 20003ee0: 2000385c 000009c5 00000000 00000000 00000000 20000414 20003fa0 0000b54f up_stackdump: 20003f00: 00009dd6 00000000 00013437 00000000 00000000 00000000 20000000 00000018 up_stackdump: 20003f20: 00000003 20003f58 00000000 00000c03 00000018 000010e3 20001e5c 00000ab9 up_stackdump: 20003f40: 00000000 00000000 00000000 20000a78 00000000 000002ab 20003fa0 00000000 up_stackdump: 20003f60: 20000819 20006f8c 20000a78 00000000 00000000 00000000 00000000 00000000 up_stackdump: 20003f80: 20000a78 00000000 00000000 00004a64 20000414 0000b54f 00009dd6 21000000 up_stackdump: 20003fa0: 20000a78 00004000 20006f8c 00004000 2000077c 00009d5d 00000000 0000b54f up_stackdump: 20003fc0: 00000000 20000a78 00004000 00000000 20000a78 0000fd1d 20001f2c 0000b7f1 up_stackdump: 20003fe0: 00000000 0000b34b 200007f0 20000a74 00000000 0000ff3f 200007f8 00001ee9 up_stackdump: 20004000: 00000000 00001bcf ffffffff 00000000 20001de8 00020000 00000000 00000101 up_stackdump: 20004020: 00000000 00000000 00000000 0000144b 00000101 0000140f 00000000 00000000
After much debugging and with Greg’s help I noticed the “srcipaddr” was not aligned:
(gdb) 194 net_ipv4addr_hdrcopy(ipv4->srcipaddr, &dev->d_ipaddr); (gdb) p &ipv4->srcipaddr $1 = (uint16_t (*)[2]) 0x20000c41 (gdb) p &dev->d_ipaddr $2 = (in_addr_t *) 0x20000eac
See, it was at 0x20000c41 that is an odd address position.
Almost instantly Greg found the source of this issue: it was the TUN/TAP driver that was defining the read_buf at odd position:
142 bool read_wait; 143 144 uint8_t read_buf[CONFIG_NET_TUN_PKTSIZE]; 145 size_t read_d_len; 146 uint8_t write_buf[CONFIG_NET_TUN_PKTSIZE];
Moving the “size_t read_d_len;” to the line above read_buf[] fixed the issue!
Now ping is not crashing and I was able to ping the Google’s DNS 8.8.8.8:
nsh> ping 8.8.8.8 PING 8.8.8.8 56 bytes of data 56 bytes from 8.8.8.8: icmp_seq=0 time=1010 ms 56 bytes from 8.8.8.8: icmp_seq=2 time=1260 ms 56 bytes from 8.8.8.8: icmp_seq=2 time=370 ms 56 bytes from 8.8.8.8: icmp_seq=4 time=1080 ms 56 bytes from 8.8.8.8: icmp_seq=4 time=490 ms 56 bytes from 8.8.8.8: icmp_seq=5 time=870 ms 56 bytes from 8.8.8.8: icmp_seq=6 time=560 ms 56 bytes from 8.8.8.8: icmp_seq=7 time=930 ms 56 bytes from 8.8.8.8: icmp_seq=8 time=640 ms 56 bytes from 8.8.8.8: icmp_seq=9 time=1010 ms 10 packets transmitted, 10 received, 0% packet loss, time 10100 ms