Something I don't understand (loops and interrupts)

2020-04-03 Thread BERTRAND Joël
Hello, I'm trying to use avr-gcc to write a trivial firmare and my code doesn't run as expected. I have tried to find a solution without any result. My current source code is available on https://hilbert.systella.fr/test.tar.gz I have designed a PCB with an

Re: Something I don't understand (loops and interrupts)

2020-04-03 Thread BERTRAND Joël
Jim Jackson a écrit : > > Not looked too closely, but ... > > On Fri, 3 Apr 2020, BERTRAND Joël wrote: > >> ISR(TIMER1_COMPA_vect, ISR_BLOCK) >> { >> uint8_t i; >> >> interrupt_counter = (interrupt_counter + 1) % 25;

[solved] Re: Something I don't understand (loops and interrupts)

2020-04-03 Thread BERTRAND Joël
I have written in a header : static gpio_t i_led[i_max] = { { , , 3, 0 }, { , , 4, 0 }, { , , 5, 0 }, { , , 6, 0 }, { , , 7, 0 }, { , , 0, 0 },

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
Strange. Following function runs as expected. enum ldl_mac_status LDL_MAC_otaa(struct ldl_mac *self) { enum ldl_mac_status retval; union ldl_mac_response_arg arg; LDL_PEDANTIC(self != NULL) if(self->ctx.joined){ retval = LDL_STATUS_JOINED; } else

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
BERTRAND Joël a écrit : > Trampas Stern a écrit : >> Does the code run if you comment out 'lora_send("coucou", 7); > > Yes. To be honnest, if I comment out LDL_MAC_otaa(), it runs. > >> Does it still crash with simple main() { _delay_ms(1000); >> s

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
Trampas Stern a écrit : > Also when you print out the size in the make file, how much SRAM does it > indicate your program is using?  AVR Memory Usage Device: atmega1284 Program: 101324 bytes (77.3% Full) (.text + .data + .bootloader) Data: 6890 bytes (42.1% Full) (.data

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
David Brown a écrit : > On 22/06/2021 18:00, Ian Molton wrote: >> On 22/06/2021 12:59, BERTRAND Joël wrote: >>> Hello, >>> >>> I'm writing a firmware for a board that uses a ATMega 1284. Firmware >>> continuously restarts >> >>

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
Trampas Stern a écrit : > Does the code run if you comment out 'lora_send("coucou", 7); Yes. To be honnest, if I comment out LDL_MAC_otaa(), it runs. > Does it still crash with simple main() { _delay_ms(1000); > stty_print("hello");} > > That is start removing code until it works, when

Re: Memory corruption (?) I don't understand

2021-06-23 Thread BERTRAND Joël
Some news. In lorawan/ldl_mac.c is defined LDL_MAC_otaa : enum ldl_mac_status LDL_MAC_otaa(struct ldl_mac *self) { enum ldl_mac_status retval; union ldl_mac_response_arg arg; LDL_PEDANTIC(self != NULL) if(self->ctx.joined){ retval = LDL_STATUS_JOINED;

Re: Memory corruption (?) I don't understand

2021-06-23 Thread BERTRAND Joël
Comparaison between good.S and bad.S. Good.elf is compiled with : app_handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, ); instead of bad.elf that is compiled with : self->handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, ); in enum ldl_mac_status LDL_MAC_otaa(struct ldl_mac *self)

Re: Memory corruption (?) I don't understand

2021-06-23 Thread BERTRAND Joël
David Brown a écrit : > On 23/06/2021 10:37, BERTRAND Joël wrote: > >> In bad.S, self->handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, ) gives : >> a340: 68 01 movwr12, r16 >> a342: ff e4 ldi r31, 0x4F ; 79 >>

Re: Memory corruption (?) I don't understand

2021-06-23 Thread BERTRAND Joël
Senthil Kumar a écrit : > What version of the compiler are you using? I have seen this bug with Debian compiler : hilbert:[~] > avr-gcc -v Using built-in specs. Reading specs from /usr/lib/gcc/avr/5.4.0/device-specs/specs-avr2 COLLECT_GCC=avr-gcc

Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
Hello, I'm writing a firmware for a board that uses a ATMega 1284. Firmware continuously restarts and I'm not able to fix this bug. It looks like a memory corruption, but after several days without finding this bug, I doubt. Hardware seems to be bug free and runs as expected.

Re: Memory corruption (?) I don't understand

2021-06-22 Thread BERTRAND Joël
Trampas Stern a écrit : > Can you comment out lines and have firmware run?   I don't understand. I have tried to comment out some lines. Sometimes firmware runs as expected, sometimes, it continuously reboots. When I comment out some lines or add some debug trace, firmware desn't

Re: Of course, I have a memory corruption, but I'm not able to fix it...

2021-05-21 Thread BERTRAND Joël
Trampas Stern a écrit : > You also  need to send the rest of the code.  > > For example it could be that rx_len is where memory overflow is happening > > cascade: > *    rx_len = sizeof(sak);* > snprintf(t, 3, "%d", (*tag).level); > > On Thu, May 20, 2021 at 11:07 AM Trampas Stern

Re: avr-crypto-lib

2021-06-01 Thread BERTRAND Joël
RSA doesn't run as expected. With expopent=3 and length=512, program doesn't crash but after four hours (@ 16 MHz on simavr), gdb shows that program stays in RSA subroutines and doesn't return to main routine. Something is probably broken somewhere. I have found a uECC library but I don't

Of course, I have a memory corruption, but I'm not able to fix it...

2021-05-20 Thread BERTRAND Joël
Hello, I'm writting a CLRC632 driver for an ATmega1284. For a while, trace were sent to a VFD screen but there is a lot of information and this screen is too little to be usable. Thus, I have configured a serial port with RTS/CTS lines with avr-usart-lib . My config

Re: Build gcc 10.3.0 for avr on a amd64 linux host

2021-05-23 Thread BERTRAND Joël
Senthil Kumar a écrit : > On Sat, May 22, 2021 at 1:21 AM BERTRAND Joël > wrote: >> >> Hello, >> >> I'm trying to build a recent gcc to check if my issue comes from >> compiler or not. Thus, I have downloaded gcc 10.3.0 sources. Of course, &g

Re: avr-crypto-lib

2021-05-29 Thread BERTRAND Joël
Nigel Winterbottom a écrit : > I took a quick look and attempted to compile your Crypto library in > Visual Studio. > > I got nowhere: Probably for good reasons; Microsoft C doesn't allow > dynamic array size like this: > >   bigint_word_t d_b[a->length_W + b->length_W]; > > This is about as

Re: avr-crypto-lib

2021-05-29 Thread BERTRAND Joël
David Brown a écrit : > On 29/05/2021 14:37, BERTRAND Joël wrote: >> Nigel Winterbottom a écrit : >>> I took a quick look and attempted to compile your Crypto library in >>> Visual Studio. >>> >>> I got nowhere: Probably for good reasons; Microsof

avr-crypto-lib

2021-05-28 Thread BERTRAND Joël
Hello, I beg your pardon as my question is not related to gcc itself. I have added to my firmware a subset of avr-crypto-lib (AES and RSA). If AES128/192/256 run as expected, RSA causes a memory corruption. Of course, I don't generate RSA key on AVR. I create this key

Build gcc 10.3.0 for avr on a amd64 linux host

2021-05-21 Thread BERTRAND Joël
Hello, I'm trying to build a recent gcc to check if my issue comes from compiler or not. Thus, I have downloaded gcc 10.3.0 sources. Of course, on my debian/testing workstation, I have avr avr-binutils and avr-libc. I have configured gcc with :

Re: Of course, I have a memory corruption, but I'm not able to fix it...

2021-05-22 Thread BERTRAND Joël
Paweł Si a écrit : > > > pt., 21 maj 2021 o 12:09 BERTRAND Joël <mailto:joel.bertr...@systella.fr>> napisał(a): > > Trampas Stern a écrit : > > You also  need to send the rest of the code.  > > > This was actually a good advice, most like

Re: Of course, I have a memory corruption, but I'm not able to fix it...

2021-05-22 Thread BERTRAND Joël
Paweł Si a écrit : > > sob., 22 maj 2021 o 09:49 BERTRAND Joël <mailto:joel.bertr...@systella.fr>> napisał(a): > >         I'm not sure. In main() you will find : > >         rfid_tag_t  tag; >         iso14443a_anticol(0, ); > > > I would

Re: Build gcc 10.3.0 for avr on a amd64 linux host

2021-05-31 Thread BERTRAND Joël
Senthil Kumar a écrit : > The following configure/make/make install worked just fine > > $ ~/src/gcc-10.3.0/configure --target=avr --enable-languages=c,c++ > --prefix=/home/saaadhu/install --disable-nls --disable-libssp > --with-dwarf2 > > I suspect fortran in --enable-languages is what is

Re: avr-crypto-lib

2021-06-01 Thread BERTRAND Joël
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 bg a écrit : > >>> RSA doesn't run as expected. With expopent=3 and length=512, >>> program doesn't crash but after four hours (@ 16 MHz on >>> simavr), gdb shows that program stays in RSA subroutines and >>> doesn't return to main routine.

Re: Memory corruption (?) I don't understand

2021-06-24 Thread BERTRAND Joël
Senthil Kumar a écrit : > https://gcc.gnu.org/bugzilla/ > > You would need a reduced testcase/preprocessed file (xxx.i obtained by > compiling with -save-temps) to debug the issue - the .S file isn't > useful to debug the compiler. Done.

Re: Memory corruption (?) I don't understand

2021-06-24 Thread BERTRAND Joël
Senthil Kumar a écrit : > This looks like a miscompilation to me. ... > What version of the compiler are you using? Can you make a reduced > testcase containing just the LDL_MAC_otaa function? Just a question. Should I fill a bug report ? And if yes, where ? Best regards,

Re: Miscompilation (gcc + inline asmb)

2021-08-15 Thread BERTRAND Joël
Some news. I remember I have used uECC a long time ago without this kind of bug. I have rebuilt the same code (with uECC_avr defined), but I have compiled this library not with gcc 11.1.0, but with 5.4.0. And I obtain : simavr -t -m atmega1284 -f 1600 test2.elf

Re: Miscompilation (gcc + inline asmb)

2021-08-15 Thread BERTRAND Joël
Some news. I remember I have used uECC a long time ago without this kind of bug. I have rebuilt the same code (with uECC_avr defined), but I have compiled this library not with gcc 11.1.0, but with 5.4.0. And I obtain : simavr -t -m atmega1284 -f 1600 test2.elf

Re: Miscompilation (gcc + inline asmb)

2021-08-13 Thread BERTRAND Joël
Some news. I have uploaded a simple example at https://hilbert.systella.fr/public/test_uecc.tar.gz This tarball contains minimal code to trigger this issue, makefile and two asmb output : - ok.asm - ko.asm ok.asm runs as expected and was built with #define

Miscompilation (gcc + inline asmb)

2021-08-10 Thread BERTRAND Joël
Hello, I'm using microecc library (https://github.com/kmackay/micro-ecc) on an ATmega 1284 CPU and it only runs as expected if I define uECC_arch_other. When library is built with uECC_avr, all tests fail. For example, I have written this simple test: #include void stty_print(unsigned char *);