Commit Graph

47518 Commits

Author SHA1 Message Date
Zhe Weng 025430a964 net/icmpv6: Fix icmpv6_reply function
Fix icmpv6_reply logic broken by commit 48311cc61f and 391b501639.

- 48311cc61f "Fix unaligned memory access when creating ICMP Port Unreachable messages"
  - It removed `htonl` function outside `data`, then the byte order may be wrong, so add `htons` back.
- 391b501639 "net: extract l3 header build code into new functions"
  - It mis-removed the `memmove`, and the icmpv6 has no payload copied after this commit.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-02 15:26:45 +08:00
Zhe Weng 69cbcfd19f net/ipfwd: Support ICMPv6 error reply when forwarding IPv6
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-02 15:26:45 +08:00
Zhe Weng f416fd86bb net/ipfwd: Support ICMP error reply when forwarding IPv4
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-02 15:26:45 +08:00
Zhe Weng da6ab79d65 net/ipv4_input: Set IPv4 flag at the same place as ipv6_input
Set IPv4 flag before processing ipforward, otherwise the ICMP packet responded by ipforward may sometimes be regarded as IPv6.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-02 15:26:45 +08:00
chao an c1c17794f9 arm/arm: generating assemble code in ARM states by default
The following changes omit the arm version:

| commit d321080351
| Author: chao an <anchao@xiaomi.com>
| Date:   Fri Dec 2 02:52:18 2022 +0800
|
|     arm/cortex-[a|r]: generating assemble code in ARM states by default
|
|     Signed-off-by: chao an <anchao@xiaomi.com>

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-02 13:54:17 +08:00
YAMAMOTO Takashi fc4493b7f1 esp32-devkitc/wamr_wasi_debug: enable native-lib stuff
* enable DLFCN.

* bump WAMR to a version which i happened to test.

* enable bulk-memory because it's required by recent versions of
  wasi-sdk, which i happened to use to build a test module.
  (test.wasm in the log below.)

Lightly tested with a stripped down version of WAMR native-lib example. [1]

```
nsh> mount -t littlefs /dev/esp32flash /mnt
nsh> iwasm --native-lib=/mnt/test_add.o /mnt/test.wasm
Hello World!
10 + 20 = 30
nsh> iwasm /mnt/test.wasm
[00:00:23:000 - 6]: warning: failed to link import function (env, test_add)
Hello World!
Exception: failed to call unlinked import function (env, test_add)
nsh>
```

[1] https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/samples/native-lib
2022-12-02 13:47:20 +08:00
Peter Bee 87e16c3694 drivers/video: add support for yuv420p
Add calc functions for buffer size (yuv420p is 6Byte/4px)

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2022-12-02 13:18:20 +08:00
Peter Bee 365b1f4bb8 drivers/video: add support for YUYV format
Add YUYV format which is used by most USB Cameras

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2022-12-02 13:18:20 +08:00
wangbowen6 84fa994f51 rpmsgdev: rpmsgdegv ioctl and seek buf fix
1. rpmsgdev ioctl: should assgin back the client return value to
   cookie->result, then this return value can be returned to the
   application;
2. rpmsgdev seek: the type "off_t" may be 64bit, so modify the offset
   in "struct rpmsgdev_lseek" to int64_t too;
3. rpmsgdev_seek: the rpmsgdev_seek in client should update the
   filep->f_pos after the seek operation;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-12-02 12:05:53 +08:00
TimJTi b6c148e763 Style changes for sam_adc.c and sam_tsd.c 2022-12-02 01:09:25 +01:00
chao an 77aede7c87 arm/thumb: outputs an implicit IT block to avoid build break
Fix build break on thumb2 mode:
opus/celt/arm/celt_pitch_xcorr_arm-gnu.S: Assembler messages:
opus/celt/arm/celt_pitch_xcorr_arm-gnu.S:146: Error: thumb conditional instruction should be in IT block -- `movle pc,lr'

Reference:
https://developer.arm.com/documentation/100067/0612/armclang-Command-line-Options/-mimplicit-it

In A32 code, the integrated assembler accepts all conditional instructions
without giving an error or warning. In T32 code, the integrated assembler
outputs an implicit IT block when there is a conditional instruction
without an enclosing IT block. The integrated assembler does not give an
error or warning about this.

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-01 22:14:34 +01:00
chao an 9ab97df0a5 arm/cortex-[a|r]/thumb: force assembler files to be interpreted as Thumb code
The option '-mthumb' is only valid for C source files and it is not passed to the assembler.

If 'thumb' is not considered in some assembly projects, the system will generate
'undefined instructions' when running incompatible instruction:

arm_undefinedinsn: Undefined instruction at 0x380cfc98

This assembly file should be compiled with .thumb but it doesn't:

380cfc90 <hobot_i8_i32_gemm_nn_m4_n8_neon>:
380cfc90: e92d4ff0  push  {r4, r5, r6, r7, r8, r9, sl, fp, lr}
380cfc94: ed2d8b10  vpush {d8-d15}
380cfc98: e59d4064  ldr r4, [sp, #100]  ; 0x64   <-- Undefined instruction
380cfc9c: e59d5068  ldr r5, [sp, #104]  ; 0x68
380cfca0: e59d606c  ldr r6, [sp, #108]  ; 0x6c
380cfca4: e59d7070  ldr r7, [sp, #112]  ; 0x70
380cfca8: e1a08120  lsr r8, r0, #2
380cfcac: e1a091a1  lsr r9, r1, #3
380cfcb0: e1a0a122  lsr sl, r2, #2

After enable thumb:
  .syntax unified
  .thumb
or
  -Wa,-mthumb

.Lhobot_i8_i32_gemm_nn_m4_n8_neon:
38001100: e92d 4ff0   stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
38001104: ed2d 8b10   vpush {d8-d15}
38001108: 9c19        ldr r4, [sp, #100]  ; 0x64
3800110a: 9d1a        ldr r5, [sp, #104]  ; 0x68
3800110c: 9e1b        ldr r6, [sp, #108]  ; 0x6c
3800110e: 9f1c        ldr r7, [sp, #112]  ; 0x70
38001110: ea4f 0890   mov.w r8, r0, lsr #2
38001114: ea4f 09d1   mov.w r9, r1, lsr #3
38001118: ea4f 0a92   mov.w sl, r2, lsr #2

This commit will enable the thumb option of the assembly file by default,
so that when compiling the assembly file, the machine code and the system will be in a consistent state.

----------------------------------------------------------------
https://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/ARM-Options.html

GCC Manual:
-mthumb
  Generate code for the Thumb instruction set. The default is to use the 32-bit ARM
  instruction set. This option automatically enables either 16-bit Thumb-1 or mixed 16/32-bit
  Thumb-2 instructions based on the -mcpu=name and -march=name options.

  ** This option is not passed to the assembler. **
  ** If you want to force assembler files to be interpreted as Thumb code,
     either add a `.thumb' directive to the source or pass the -mthumb option
     directly to the assembler by prefixing it with -Wa. **

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-01 22:14:34 +01:00
chao an d321080351 arm/cortex-[a|r]: generating assemble code in ARM states by default
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-01 22:14:34 +01:00
YAMAMOTO Takashi 8ee2ed0b91 littlefs: add a few Kconfig options 2022-12-01 23:34:31 +08:00
YAMAMOTO Takashi a43af6563b esp32-devkitc:wamr_wasi_debug kconfig maintainance
* disable too verbose wamr options.

* enable CONFIG_SCHED_WAITPID. because async execution on nsh prompt
  sometimes confuses me.

* enable toywasm. it's sometimes convenient to have another interpreter.
  note: wasm3 in nuttx apps doesn't have wasi enabled.
2022-12-01 23:28:33 +08:00
Zhe Weng 9aefd6717c net/nat: Add support for ICMP Error Message
Support DEST_UNREACHABLE, TIME_EXCEEDED and PARAMETER_PROBLEM ICMP types in NAT.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-01 22:45:22 +08:00
Zhe Weng 23dfdeacab net/nat: Split out ipv4_nat_in/outbound_internal
Split out ipv4_nat_in/outbound_internal which returns entry instead of error code, for later ICMP error types, does not change any current logic.

Reason: Outer packet doesn't have information of port, so we need to find entry by inner packet, and apply the entry to outer packet.

| Outer Packet: SRC = Peer IP<No Port>, DST = External IP<No Port> |
| Inner Packet: SRC = External IP:Port, DST = Peer IP:Port         |

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-01 22:45:22 +08:00
Zhe Weng 8b211128f1 net/nat: Support param to manipulate src or dest
This commit is for later ICMP error types processing, and does not change any current logic.

Reason for supporting both side of modification is that an inbound ICMP Error MSG may carry original packet like this:

|          IP HDR: SRC = Peer IP,       DST = External IP |
|        ICMP HDR: ERROR MSG                              |
| <Origin> IP HDR: SRC = External IP,   DST = Peer IP     |
| <Origin> L4 HDR: SRC = External Port, DST = Peer Port   |

So we need to support inbound translation (External -> Local) on SRC or DST of each header.

And so do the outbound direction.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-01 22:45:22 +08:00
Peter van der Perk 90472785d3 S32K3XX QSPI No need to check TX FIFO buffer when MPU is correctly configured 2022-12-01 08:00:32 -05:00
Peter van der Perk ec5030ebe6 S32K3XX RAM fixes MPU Dcache ECC 2022-12-01 08:00:32 -05:00
Zhe Weng 3aac6a1a3b net/devif: fix devif loopback
devif_loopback needs to be applied on l2 data, and was broken by commit below, now fix it.

| commit 8850dee746
| Author: chao an <anchao@xiaomi.com>
| Date:   Sun Nov 27 03:31:07 2022 +0800
|
|     net/devif: move preprocess of txpoll into common code
|
|     Signed-off-by: chao an <anchao@xiaomi.com>

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-01 19:48:23 +08:00
Masayuki Ishikawa f7937d11a2 arch: arm64: Fix qemu_pl011_txint() in qemu_serial.c
Summary:
- I noticed that the nsh prompt can not be shown when disabling
  debug features. Actually, the prompt will be shown when a user
  input happens.
- This commit fixes this issue by adding uart_xmitchars() as
  other serial drivers do.

Impact:
- None

Testing:
- Tested with qemu-armv8a:netnsh on QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-12-01 19:38:03 +08:00
Masayuki Ishikawa 3b2685409a arch: risc-v: Fix nsec overflow in riscv_mtimer_current()
Summary:
- I noticed that mtimer stops around 30min after boot.
- Finally, I found that nesc overflows in riscv_mtimer_current().
- This commit fixes this issue.

Impact:
- None

Testing:
- Tested with rv-virt:nsh on QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-12-01 19:33:39 +08:00
FASTSHIFT 0ae242aa8d drivers/video/fb: add poll support
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
2022-12-01 15:08:03 +08:00
dongjiuzhu1 b1b2a7cc0b timerfd_create: initial reference count to zero
nx_open in timerfd_create will increase reference count,
Therefore, the reference count starts with a value of 0.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-01 15:07:09 +08:00
pengyiqiang c4535ee66a drivers/input/touchscreen_upper: add missing function code comments
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
2022-12-01 10:26:11 +08:00
chao an 12b0fa9ec3 arm/sama5: fix recursive dependency
arch/arm/src/sama5/Kconfig:819:error: recursive dependency detected!
For a resolution refer to Documentation/kbuild/kconfig-language.txt
subsection "Kconfig recursive dependency limitations"
arch/arm/src/sama5/Kconfig:819:	choice <choice> contains symbol SAMA5_FLEXCOM0_USART
For a resolution refer to Documentation/kbuild/kconfig-language.txt
subsection "Kconfig recursive dependency limitations"
arch/arm/src/sama5/Kconfig:824:	symbol SAMA5_FLEXCOM0_USART is part of choice SAMA5_FLEXCOM0_USART
For a resolution refer to Documentation/kbuild/kconfig-language.txt
subsection "Kconfig recursive dependency limitations"
arch/arm/src/sama5/Kconfig:824:	symbol SAMA5_FLEXCOM0_USART is part of choice <choice>

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-01 09:45:09 +08:00
chao an a0bce18192 net/ipv4: fix shadows declaration
devif/ipv4_input.c: In function ‘ipv4_in’:
devif/ipv4_input.c:305:15: warning: declaration of ‘ret’ shadows a previous local [-Wshadow]
  305 |           int ret = ipv4_forward(dev, ipv4);
      |               ^~~
devif/ipv4_input.c:151:7: note: shadowed declaration is here
  151 |   int ret = OK;
      |       ^~~

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-01 09:38:33 +08:00
TimJTi a634da9a30 Fix SAMA5D2 ADC and TSD problems
SAMA5Dx ADC and TSD fixes

Ensures ADC and TSD work together. TSD now works on SAMA5D2 and should be OK, still, for other SAMA5D familiy members

Fix CI error

checkpatch error

Update arch/arm/src/sama5/sam_tsd.h

Squash commits to arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Update arch/arm/src/sama5/hardware/sam_adc.h

Squash commits to arch/arm/src/sama5/sam_tsd.c

Update arch/arm/src/sama5/sam_tsd.c

Update arch/arm/src/sama5/sam_tsd.c

Update arch/arm/src/sama5/sam_tsd.c

Update sam_tsd.c

Fixes after feedback from PR and additional testing

Update sam_tc.c

checkpatch.sh error was missed when fixing someone else's error...

feedback corrections missed

Co-Authored-By: Xiang Xiao <xiaoxiang781216@gmail.com>
Co-Authored-By: Petro Karashchenko <petro.karashchenko@gmail.com>

squashed everything after 248072e02C
2022-12-01 01:51:12 +08:00
zouboan 498bc98b1b tools/Win.mk:Fix an pass1dep error when USERDEPDIRS is empty in Windows native build 2022-12-01 01:47:46 +08:00
zouboan f115a97bdc tools/Config:Fix too long input line error call ARCHIVE when use too many libc in Windows native build
tools/Config:Fix too long input line error call ARCHIVE when use too many libc in Windows native build
2022-12-01 01:47:46 +08:00
zouboan 20c69294db tools/Win.mk:Fix an issue in mkdir -p in Windows native build 2022-12-01 01:47:46 +08:00
zouboan 744df68b10 tools/Win.mk:Fix some error in clean_context in Windows native build 2022-12-01 01:47:46 +08:00
zouboan eaea38e0f2 libc and mm/Makefile:Fix an error caused by backslash in Windows native build
libc and mm/Makefile:Fix an error caused by backslash in Windows native build
2022-12-01 01:47:46 +08:00
zouboan e2c2cc16ee tools/Config:Fix some error call DELFILE/DELDIR/CATFILE/CLEAN in Windows native build
tools/Config:Fix some error call DELFILE/DELDIR/CATFILE  in Windows native build
2022-12-01 01:47:46 +08:00
zouboan fd9838f41f tools/mkdeps:Fix an error caused by do_shquote in Windows native build
tools/mkdeps:Fix an error caused by do_shquote in Windows native build

tools/mkdeps:Fix an error caused by do_shquote in Windows native build
2022-12-01 01:47:46 +08:00
TimJTi 57a21fbe1a Fixes for SAMA5D2 Flexcom USART
squashed everything after 8f8b8f5e05

Update Kconfig

Update Kconfig
2022-11-30 23:14:17 +08:00
flyingfish89 fa59db8cea Add Hexadecimal parsing for strtof
solve:
  almost the Hexadecimal string string->float
such as:
  code:float num;
       const char *s= "0x123p32lala";
       char *p;
       num=strtof(s,&p);
       printf("num is %f\n",num);
       printf("str is %s\n",p);
  output:num is 1249835483136.000000
         str is lala

but if the input number is much big;
like:
  code:const char *s2= "0x999999p100";
       num=strtof(s2,&p);
       printf("num is %f\n",num);
       printf("str is %s\n",p);
  corrent : num is 12760587998944832242938906880669384704.000000
  real:     num is 12760587998944800000000000000000000000.000000
it didn't have enough precision
2022-11-30 19:03:07 +08:00
chao an 4281acdb83 net/chksum: move all chksum api declarations to common header
The following APIs need to be overriden by the arch after enabling
CONFIG_NET_ARCH_CHKSUM, move these functions to the common header
file to avoid prototype conflicts

uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev,
                                uint8_t proto, unsigned int iplen);
uint16_t ipv4_chksum(FAR struct ipv4_hdr_s *ipv4);

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-30 15:08:14 +08:00
chao an 0de9e387a7 net/loopback: reuse devif_loopback() logic for device lo(loopback)
TX poll callback in device lo(loopback) can be replaced by devif_loopback()
from devif_poll() hook, remove duplicate code to reuse this logic

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-30 10:07:14 +08:00
chao an 823252261f net/devif: remove link layer length from loopback
Add link layer length in loopback is unnecessary after below change checkin:

 | commit 6fa60627eb
 | Author: chao an <anchao@xiaomi.com>
 | Date:   Sun Nov 27 02:13:21 2022 +0800
 |
 |     net/devif/ip: build l2 header on the IP layer
 |
 |     Signed-off-by: chao an <anchao@xiaomi.com>

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-30 10:07:14 +08:00
liyi 391b501639 net: extract l3 header build code into new functions
Signed-off-by: liyi <liyi25@xiaomi.com>
2022-11-29 18:36:15 +08:00
chao an d54a20b393 net/tcp/udp: remove all domain assertion
fix build break if enable CONFIG_NET_IPv6 only

In file included from tcp/tcp_sendfile.c:38:
tcp/tcp_sendfile.c: In function ‘sendfile_eventhandler’:
tcp/tcp_sendfile.c:173:27: error: ‘struct tcp_conn_s’ has no member named ‘domain’
  173 |           DEBUGASSERT(conn->domain == PF_INET6);
      |                           ^~

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 17:28:36 +08:00
flyingfish89 bb040befee optimize the code of the printf 2022-11-29 17:27:02 +08:00
Masayuki Ishikawa 3377aa23ca boards: qemu-armv8a: Add virtio-net to netnsh/netnsh_smp
Summary:
- This commit adds virtio-net to netnsh/netnsh_smp

Impact:
- None

Testing:
- Tested iperf and telnetd with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
Masayuki Ishikawa 1eb3d01956 arch: arm64: Add qemu_virtio.c
Summary:
- This commit adds qemu_virtio.c

Impact:
- None

Testing:
- Tested with qemu-armv8a:netnsh (will be added later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
Masayuki Ishikawa b1ebca68f1 arch: arm64: Remove arm64_netinitialize() from qemu_boot.c
Summary:
- This commit removes arm64_netinitialize() from qemu_boot.c

Impact:
- None

Testing:
- Tested with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
Masayuki Ishikawa 5c8d9c928a boards: rv-virt: Add virtio-net to netnsh/netnsh_smp/netnsh64
Summary:
- This commit add virtio-net to netnsh/netnsh_smp/netnsh64

Impact:
- None

Testing:
- Tested iperf and telnetd with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
Masayuki Ishikawa 8053931d31 arch: qemu-rv: Add qemu_rv_virtio.c
Summary:
- This commit adds qemu_rv_virtio.c

Impact:
- None

Testing
- Tested with rv-virt:netnsh (will be added later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
Masayuki Ishikawa 8b4ffb8d3e virtio: Add virtio drivers
Summary:
- This commit adds virtio-mmio and virtio-net drivers

Impact:
- None (new drivers)

Testing:
- Tested with rv-virt (will be updated later) with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00