broken AVR demos Topic is solved

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

Moderators: utzig, tfAteba

szilveszter
Posts: 6
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 5 times
Been thanked: 1 time
Contact:

broken AVR demos

Postby szilveszter » Mon Jun 14, 2021 5:59 pm

Hi,

I am new to ChibiOS and started to play with the demos. The new 21.6.0 version somehow broke the demos/AVR/NIL-ARDUINO-UNO and demos/AVR/RT-ARDUINO-UNO demos (I tried only these two). FYI. they work perfectly with 20.3.3. I compiled them with the AVR GCC from the Arduino installation directory and also with a custom own compiled AVR-GCC. Finally I flashed them with avrdude over the serial/usb cable the same way as Arduino IDE does. The version 20.3.3 works perfectly, however the 21.6.0 doesn't.

Best regards,
Szilveszter Zsigmond

User avatar
Giovanni
Site Admin
Posts: 13632
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 891 times
Been thanked: 770 times
Contact:

Re: broken AVR demos  Topic is solved

Postby Giovanni » Mon Jun 14, 2021 6:07 pm

Hi,

Thanks for finding, The AVR port is not yet tested on 21.6.0 (which is a release candidate), I will look at changes between versions.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 13632
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 891 times
Been thanked: 770 times
Contact:

Re: broken AVR demos

Postby Giovanni » Mon Jun 14, 2021 6:22 pm

Hi again,

I don't know if this is the only problem but in chcore.c you should put this code:

Code: Select all

void _port_switch(thread_t *ntp, thread_t *otp) {

  (void)ntp;
  (void)otp;

  asm volatile ("push    r2");
  asm volatile ("push    r3");
  asm volatile ("push    r4");
  asm volatile ("push    r5");
  asm volatile ("push    r6");
  asm volatile ("push    r7");
  asm volatile ("push    r8");
  asm volatile ("push    r9");
  asm volatile ("push    r10");
  asm volatile ("push    r11");
  asm volatile ("push    r12");
  asm volatile ("push    r13");
  asm volatile ("push    r14");
  asm volatile ("push    r15");
  asm volatile ("push    r16");
  asm volatile ("push    r17");
  asm volatile ("push    r28");
  asm volatile ("push    r29");

#if defined(__CHIBIOS_RT__)
  asm volatile ("movw    r30, r22");
  asm volatile ("in      r0, 0x3d");
  asm volatile ("std     Z+5, r0");
  asm volatile ("in      r0, 0x3e");
  asm volatile ("std     Z+6, r0");

  asm volatile ("movw    r30, r24");
  asm volatile ("ldd     r0, Z+5");
  asm volatile ("out     0x3d, r0");
  asm volatile ("ldd     r0, Z+6");
  asm volatile ("out     0x3e, r0");
#endif

#if defined(__CHIBIOS_NIL__)
  asm volatile ("movw    r30, r22");
  asm volatile ("in      r0, 0x3d");
  asm volatile ("std     Z+0, r0");
  asm volatile ("in      r0, 0x3e");
  asm volatile ("std     Z+1, r0");

  asm volatile ("movw    r30, r24");
  asm volatile ("ldd     r0, Z+0");
  asm volatile ("out     0x3d, r0");
  asm volatile ("ldd     r0, Z+1");
  asm volatile ("out     0x3e, r0");
#endif

  asm volatile ("pop     r29");
  asm volatile ("pop     r28");
  asm volatile ("pop     r17");
  asm volatile ("pop     r16");
  asm volatile ("pop     r15");
  asm volatile ("pop     r14");
  asm volatile ("pop     r13");
  asm volatile ("pop     r12");
  asm volatile ("pop     r11");
  asm volatile ("pop     r10");
  asm volatile ("pop     r9");
  asm volatile ("pop     r8");
  asm volatile ("pop     r7");
  asm volatile ("pop     r6");
  asm volatile ("pop     r5");
  asm volatile ("pop     r4");
  asm volatile ("pop     r3");
  asm volatile ("pop     r2");
  asm volatile ("ret");
}


to replace the existing _port_switch() function. The problem was that "_CHIBIOS_RT_" changed in "__CHIBIOS_RT__" in latest release. This fix will be included in 21.6.1, committed on repository.

Giovanni

User avatar
tfAteba
Posts: 531
Joined: Fri Oct 16, 2015 11:03 pm
Location: Chartres, France
Has thanked: 83 times
Been thanked: 47 times

Re: broken AVR demos

Postby tfAteba » Tue Jun 15, 2021 8:39 am

Hello,

Thanks Giovanni, In the next days, I will take the time on to test all the AVR demo.
regards,

Theo.


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 1 guest