iot-lab / iot-lab-contiki-ng

IoT-LAB Contiki-NG port
3 stars 7 forks source link

Multicast example pointer of type 'void *' used in arithmetic warning/error #16

Closed fkerem closed 3 years ago

fkerem commented 4 years ago

Trying to build Contiki's multicast (/home/jovyan/contiki-ng/iot-lab-contiki-ng/contiki-ng/examples/multicast) example but it causes "pointer of type 'void *' used in arithmetic" error. Should I suppress the warnings being treated as errors?

command: !make -C $APP_DIR TARGET=iotlab BOARD=m3

make: Entering directory '/home/jovyan/contiki-ng/iot-lab-contiki-ng/contiki-ng/examples/multicast'
  MKDIR     build/iotlab/m3/obj
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/xmem.c
  CC        ../../os/storage/cfs/cfs-coffee.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/acc-mag-sensor.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/fake-button-sensor.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/gyr-sensor.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/light-sensor.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/pressure-sensor.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/platform/iotlab-m3/iotlab-m3.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/platform/iotlab-m3/iotlab-m3_drivers.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/platform/iotlab-m3/iotlab-m3_lib.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/platform/iotlab-m3/iotlab-m3_periph.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/lsm303dlhc/lsm303dlhc.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/lps331ap/lps331ap.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/l3g4200d/l3g4200d.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/isl29020/isl29020.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/n25xxx/n25xxx.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/cortex-m3/boot.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/cortex-m3/nvic.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/dma.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/i2c.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/spi.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/timer.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/uart.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/unique_id.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/usb.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32/watchdog.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/adc.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/afio.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/boot.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/exti.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/flash.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/gpio.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/rcc.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/rcc_clock.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/rcc_sysclk.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/rtc.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/sdio.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/drivers/stm32f1xx/stm32f1xx.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/lib/softtimer/soft_timer_delay.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/openlab/periph/rf2xx/rf2xx.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./platform.c
  CC        ../../os/dev/leds.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./int-master.c
  CC        ../../os/lib/sensors.c
  CC        ../../os/dev/slip.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./clock-systick.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./watchdog.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./radio-rf2xx.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/dev/uart1.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./slip-arch.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./openlab-port.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./rtimer-arch.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/./leds-arch.c
  CC        /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/m3/platform-sensors.c
  CC        ../../os/net/ipv6/multicast/uip-mcast6-stats.c
  CC        ../../os/net/ipv6/multicast/mpl.c
../../os/net/ipv6/multicast/mpl.c: In function 'icmp_out':
../../os/net/ipv6/multicast/mpl.c:875:33: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       memcpy(((void *)locsiptr) + seed_info_len, vector, vec_size);
                                 ^
../../os/net/ipv6/multicast/mpl.c:876:37: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + seed_info_len + vec_size;
                                     ^
../../os/net/ipv6/multicast/mpl.c:876:53: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + seed_info_len + vec_size;
                                                     ^
../../os/net/ipv6/multicast/mpl.c: In function 'data_message_expiration':
../../os/net/ipv6/multicast/mpl.c:980:34: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
     memcpy(((void *)UIP_EXT_BUF) + 8 + UIP_EXT_BUF->len * 8, &locmmptr->data, locmmptr->size);
                                  ^
../../os/net/ipv6/multicast/mpl.c:980:38: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
     memcpy(((void *)UIP_EXT_BUF) + 8 + UIP_EXT_BUF->len * 8, &locmmptr->data, locmmptr->size);
                                      ^
../../os/net/ipv6/multicast/mpl.c: In function 'icmp_in':
../../os/net/ipv6/multicast/mpl.c:1134:59: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
             (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                                                           ^
../../os/net/ipv6/multicast/mpl.c:1134:69: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
             (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                                                                     ^
../../os/net/ipv6/multicast/mpl.c:1134:21: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
             (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                     ^~~~~~~~~
../../os/net/ipv6/multicast/mpl.c:1138:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
           locsiptr = ((void *)locsiptr) + sizeof(struct seed_info) + SEED_INFO_GET_LEN(locsiptr);
                                         ^
../../os/net/ipv6/multicast/mpl.c:1138:68: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
           locsiptr = ((void *)locsiptr) + sizeof(struct seed_info) + SEED_INFO_GET_LEN(locsiptr);
                                                                    ^
../../os/net/ipv6/multicast/mpl.c:1145:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
           locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s1) + SEED_INFO_GET_LEN(locsiptr);
                                         ^
../../os/net/ipv6/multicast/mpl.c:1145:71: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s1) + SEED_INFO_GET_LEN(locsiptr);
                                                                     ^
../../os/net/ipv6/multicast/mpl.c:1152:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
           locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s2) + SEED_INFO_GET_LEN(locsiptr);
                                         ^
../../os/net/ipv6/multicast/mpl.c:1152:71: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s2) + SEED_INFO_GET_LEN(locsiptr);
                                                                     ^
../../os/net/ipv6/multicast/mpl.c:1159:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
           locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s3) + SEED_INFO_GET_LEN(locsiptr);
                                         ^
../../os/net/ipv6/multicast/mpl.c:1159:71: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s3) + SEED_INFO_GET_LEN(locsiptr);
                                                                     ^
../../os/net/ipv6/multicast/mpl.c:1190:55: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                                                       ^
../../os/net/ipv6/multicast/mpl.c:1190:65: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                                                                 ^
../../os/net/ipv6/multicast/mpl.c:1190:17: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
         (struct seed_info *)((void *)UIP_ICMP_PAYLOAD + uip_len - uip_l3_icmp_hdr_len)) {
                 ^~~~~~~~~
../../os/net/ipv6/multicast/mpl.c:1216:35: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       vector = ((void *)locsiptr) + sizeof(struct seed_info);
                                   ^
../../os/net/ipv6/multicast/mpl.c:1219:35: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       vector = ((void *)locsiptr) + sizeof(struct seed_info_s1);
                                   ^
../../os/net/ipv6/multicast/mpl.c:1222:35: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       vector = ((void *)locsiptr) + sizeof(struct seed_info_s2);
                                   ^
../../os/net/ipv6/multicast/mpl.c:1225:35: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       vector = ((void *)locsiptr) + sizeof(struct seed_info_s3);
                                   ^
../../os/net/ipv6/multicast/mpl.c:1357:37: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info) + SEED_INFO_GET_LEN(locsiptr);
                                     ^
../../os/net/ipv6/multicast/mpl.c:1357:64: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info) + SEED_INFO_GET_LEN(locsiptr);
                                                                ^
../../os/net/ipv6/multicast/mpl.c:1360:37: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s1) + SEED_INFO_GET_LEN(locsiptr);
                                     ^
../../os/net/ipv6/multicast/mpl.c:1360:67: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s1) + SEED_INFO_GET_LEN(locsiptr);
                                                                   ^
../../os/net/ipv6/multicast/mpl.c:1363:37: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s2) + SEED_INFO_GET_LEN(locsiptr);
                                     ^
../../os/net/ipv6/multicast/mpl.c:1363:67: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s2) + SEED_INFO_GET_LEN(locsiptr);
                                                                   ^
../../os/net/ipv6/multicast/mpl.c:1366:37: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s3) + SEED_INFO_GET_LEN(locsiptr);
                                     ^
../../os/net/ipv6/multicast/mpl.c:1366:67: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
       locsiptr = ((void *)locsiptr) + sizeof(struct seed_info_s3) + SEED_INFO_GET_LEN(locsiptr);
                                                                   ^
../../os/net/ipv6/multicast/mpl.c: In function 'accept':
../../os/net/ipv6/multicast/mpl.c:1575:27: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
     hptr = ((void *)hptr) + hptr->len * 8 + 8;
                           ^
../../os/net/ipv6/multicast/mpl.c:1575:43: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
     hptr = ((void *)hptr) + hptr->len * 8 + 8;
                                           ^
../../os/net/ipv6/multicast/mpl.c:1577:25: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
   hptr = ((void *)hptr) + hptr->len * 8 + 8;
                         ^
../../os/net/ipv6/multicast/mpl.c:1577:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
   hptr = ((void *)hptr) + hptr->len * 8 + 8;
                                         ^
cc1: all warnings being treated as errors
/home/jovyan/contiki-ng/iot-lab-contiki-ng/arch/platform/iotlab/Makefile.iotlab:166: recipe for target 'build/iotlab/m3/obj/mpl.o' failed
make: *** [build/iotlab/m3/obj/mpl.o] Error 1
make: Leaving directory '/home/jovyan/contiki-ng/iot-lab-contiki-ng/contiki-ng/examples/multicast'
aabadie commented 4 years ago

The problem is that contiki-ng doesn't support the arm gcc toolchain installed in the iot-lab-training docker image (7.3). Contiki-ng only supports 5.4. We are going to deploy an image with a 5.4 available, but not used as default, you will have to prepend it to your PATH.

fkerem commented 4 years ago

The problem is that contiki-ng doesn't support the arm gcc toolchain installed in the iot-lab-training docker image (7.3). Contiki-ng only supports 5.4. We are going to deploy an image with a 5.4 available, but not used as default, you will have to prepend it to your PATH.

Thank you so much, could you acknowledge this issue when it is deployed please?

aabadie commented 4 years ago

The new fitiolab/iot-lab-jupyterlab image is available on dockerhub and is deployed on labs.iot-lab.info. If you are using iot-lab-training locally (not in labs), you will have to pull the image first: docker pull fitiotlab/iot-lab-jupyterlab:latest

The ARM gcc 5 toolchain is located in /opt/gcc-arm-none-eabi-5_2-2015q4/ and you have to prepend it to your path to be able to used it instead of the default 7.3 one. Just run the following command before compiling:

export PATH=/opt/gcc-arm-none-eabi-5_2-2015q4/bin:${PATH}

Note that you'll have to run this command in each new terminal. You can also add to ~/.bashrc but this file is reset each the container of your session is started.

fkerem commented 4 years ago

The new fitiolab/iot-lab-jupyterlab image is available on dockerhub and is deployed on labs.iot-lab.info. If you are using iot-lab-training locally (not in labs), you will have to pull the image first: docker pull fitiolab/iot-lab-jupyterlab:latest

The ARM gcc 5 toolchain is located in /opt/gcc-arm-none-eabi-5_2-2015q4/ and you have to prepend it to your path to be able to used it instead of the default 7.3 one. Just run the following command before compiling:

export PATH=/opt/gcc-arm-none-eabi-5_2-2015q4/bin:${PATH}

Note that you'll have to run this command in each new terminal. You can also add to ~/.bashrc but this file is reset each the container of your session is started.

Wow, thank you so much for the quick reply and solution. I appreciate your great support!

fkerem commented 3 years ago

@aabadie I cannot pull the image even with the command IOTLAB_LOGIN=<login> docker pull fitiolab/iot-lab-jupyterlab:latest What should I do? It says:

Error response from daemon: pull access denied for fitiolab/iot-lab-jupyterlab, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Also, should I follow the steps above if I remove the old version and pull new git repo?

aabadie commented 3 years ago

I cannot pull the image even with the command

Sorry, there was a typo in the command I gave above (now fixed) and the docker image you should pull is not fitiotlab/iot-lab-jupyterlab but fitiotlab/iot-lab-training:

docker pull fitiotlab/iot-lab-training:latest

Use it only if you are running jupyterlab locally in the iot-lab-training repo. Use make run-docker as explained in the README.

fkerem commented 3 years ago

Yes, I'm running it locally but I'm still getting the compilation errors. Here is what I do from scratch: I removed local iot-lab-training folder to make a clean version. Then, followed the steps below:

docker pull fitiotlab/iot-lab-training:latest
git clone --recursive https://github.com/iot-lab/iot-lab-training
cd iot-lab-training
IOTLAB_LOGIN=<login> make run-docker
http://localhost:8888/?token=

Inside the .ipynb file where I compile the code:

!export PATH=/opt/gcc-arm-none-eabi-5_2-2015q4/bin:${PATH};echo $PATH;gcc --version;make -C $APP_DIR TARGET=iotlab BOARD=m3

I get the $PATH variable as below but still getting compilation errors: /opt/gcc-arm-none-eabi-5_2-2015q4/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/gcc-arm-none-eabi-7-2018-q2-update/bin

Even though I exclude default toolchain from the path and remove build folder to rebuild, I got the errors. /opt/gcc-arm-none-eabi-5_2-2015q4/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

aabadie commented 3 years ago

With the following code in a cell, I can reproduce the errors:

%env ARCH_PATH = /home/jovyan/contiki-ng/iot-lab-contiki-ng/arch
%env APP_DIR = /home/jovyan/contiki-ng/iot-lab-contiki-ng/contiki-ng/examples/multicast
!export PATH=/opt/gcc-arm-none-eabi-5_2-2015q4/bin:${PATH};echo $PATH;arm-none-eabi-gcc --version;make -C $APP_DIR TARGET=iotlab BOARD=m3

(if using labs.iot-lab.info, the paths are different, one should use /home/jovyan/work/training/ instead of /home/jovyan)

Unfortunately, the simplest way to the get a successful build is to add WERROR=0 to the make command. Other solutions are to correctly fix the build issues in the contiki fork, or maybe be upstream.

fkerem commented 3 years ago

@aabadie Yes, at least I could build the code (with the warnings appearing) by setting WERROR=0 in the make command. Thank you very much.