broken AVR demos Topic is solved

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

Moderator: tfAteba

Post Reply
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

broken AVR demos

Post by szilveszter »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: broken AVR demos

Post by Giovanni »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: broken AVR demos

Post by Giovanni »

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: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: broken AVR demos

Post by tfAteba »

Hello,

Thanks Giovanni, In the next days, I will take the time on to test all the AVR demo.
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: broken AVR demos

Post by tfAteba »

Hello,

Just to tell that the demos have been fixed for a while, but sorry I din't notice you since I fixed it.
Post Reply