NIL AVR depends on RT Topic is solved

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

NIL AVR depends on RT

Postby tfAteba » Mon Jun 05, 2017 9:08 am

Hi, Giovanni,

In the trunk, the current NIL demo for AVR do not compile any more, due to NIL evolution I suppose.
I look to differences against STM:
The file demo/AVR/NIL-ARDUINOUNO/nilconf.h need to be replace by demo/AVR/NIL-ARDUINOUNO/chconf.h
I then copied the file chconf.h from an STM demo and change the number of threads to 2 as it is in the AVR demo.

The line 18 in demo/AVR/NIL-ARDUINOUNO/main.c

Code: Select all

#include "nil.h"

is replaced by

Code: Select all

#include "chconf.h"


After compilation, at linking step, a get an error that shows me that NIL depends on RT :( . I thinks it must not be the case?
Here is the error:

Linking: ch.elf
avr-gcc -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=../../../os/nil/src/ch.o -I../../../os/license -I../../../os/common/ports/AVR -I../../../os/common/ports/AVR/compilers/GCC -I../../../os/nil/include -I../../../os/common/oslib/include -I../../../test/lib -I../../../test/nil/source/test -I../../../os/hal/include -I../../../os/hal/osal/nil -I../../../os/hal/ports/AVR -I../../../os/hal/boards/ARDUINO_UNO -I../../../os/various -std=gnu11 -fdata-sections -ffunction-sections -Wundef -MMD -MP -MF .dep/ch.elf.d ../../../os/nil/src/ch.o ../../../os/common/oslib/src/chmboxes.o ../../../os/common/oslib/src/chmemcore.o ../../../os/common/oslib/src/chmempools.o ../../../os/common/oslib/src/chheap.o ../../../os/common/ports/AVR/chcore.o ../../../os/hal/osal/nil/osal.o ../../../os/hal/src/hal.o ../../../os/hal/src/hal_buffers.o ../../../os/hal/src/hal_queues.o ../../../os/hal/src/hal_mmcsd.o ../../../os/hal/src/hal_adc.o ../../../os/hal/src/hal_can.o ../../../os/hal/src/hal_dac.o ../../../os/hal/src/hal_ext.o ../../../os/hal/src/hal_gpt.o ../../../os/hal/src/hal_i2c.o ../../../os/hal/src/hal_i2s.o ../../../os/hal/src/hal_icu.o ../../../os/hal/src/hal_mac.o ../../../os/hal/src/hal_mmc_spi.o ../../../os/hal/src/hal_pal.o ../../../os/hal/src/hal_pwm.o ../../../os/hal/src/hal_qspi.o ../../../os/hal/src/hal_rtc.o ../../../os/hal/src/hal_sdc.o ../../../os/hal/src/hal_serial.o ../../../os/hal/src/hal_serial_usb.o ../../../os/hal/src/hal_spi.o ../../../os/hal/src/hal_st.o ../../../os/hal/src/hal_uart.o ../../../os/hal/src/hal_usb.o ../../../os/hal/src/hal_wdg.o ../../../os/hal/ports/AVR/hal_lld.o ../../../os/hal/ports/AVR/hal_pal_lld.o ../../../os/hal/ports/AVR/hal_serial_lld.o ../../../os/hal/ports/AVR/hal_adc_lld.o ../../../os/hal/ports/AVR/hal_ext_lld.o ../../../os/hal/ports/AVR/hal_i2c_lld.o ../../../os/hal/ports/AVR/hal_spi_lld.o ../../../os/hal/ports/AVR/hal_gpt_lld.o ../../../os/hal/ports/AVR/hal_pwm_lld.o ../../../os/hal/ports/AVR/hal_icu_lld.o ../../../os/hal/ports/AVR/hal_usb_lld.o ../../../os/hal/ports/AVR/hal_st_lld.o ../../../os/hal/boards/ARDUINO_UNO/board.o ../../../test/lib/ch_test.o ../../../test/nil/source/test/test_root.o ../../../test/nil/source/test/test_sequence_001.o ../../../test/nil/source/test/test_sequence_002.o ../../../test/nil/source/test/test_sequence_003.o ../../../test/nil/source/test/test_sequence_004.o ../../../test/nil/source/test/test_sequence_005.o ../../../test/nil/source/test/test_sequence_006.o main.o --output ch.elf -Wl,-Map=ch.map,--cref,--gc-sections -Wl,-u,vfprintf -lprintf_min -Wl,-u,vfscanf -lscanf_min -lm
../../../os/common/ports/AVR/chcore.o: In function `_port_thread_start':
/home/tfateba/Documents/chibios/nil-avr/demos/AVR/NIL-ARDUINOUNO/../../../os/common/ports/AVR/chcore.c:153: undefined reference to `chThdExit'
collect2: error: ld returned 1 exit status
Makefile:498: recipe for target 'ch.elf' failed
make: *** [ch.elf] Error 1
make: Leaving directory '/home/tfateba/Documents/chibios/nil-avr/demos/AVR/NIL-ARDUINOUNO'


The asm call to chThdExit cause the failure.

By commenting the line 153 in os/common/ports/AVR/chcore.c, everything build fine.

But the program execution is too fast, an Helloworld message must be send to the serial console every 2 second, but I see it every 10ms. The same for the LED!

What do we need to do to resolve the problem?

Thanks.
regards,

Theo.

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Re: NIL AVR depends on RT  Topic is solved

Postby tfAteba » Sat Jun 10, 2017 2:31 am

Hi Giovanni,

I finally come across this problem.

First of all in the main file,nil.h have to be replaced by ch.h file instead of chconf.h has I wrote in my previous message.

The linker error was still there: undefined reference to `chThdExit
I understood that chThdExit is the function called when a thread exit is infinite loop. This is an undesired stated normally. So I found that in the current implementation of NIL chSysHalt it is the function that played the same role.

If you want to add a precisions please don't hesitate.

Thus by replacing the function chThdExit by chSysHalt, the demo compile successfully.

I have also made two runtime tests on Arduino UnO-328p and Mega-2560 boards. All demos worked as expected but can you please confirm me that the changes that I made are correct.

Thanks.
regards,

Theo.


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 16 guests