Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootloader (optiboot) and MAX485 RXTX pin #695

Open
expertup opened this issue Jun 12, 2022 · 5 comments
Open

Bootloader (optiboot) and MAX485 RXTX pin #695

expertup opened this issue Jun 12, 2022 · 5 comments
Labels
Pre-2.0.0 bug Bug present in versions of the core older than 2.0.0 - needs to be reteted in 2.0.0

Comments

@expertup
Copy link

expertup commented Jun 12, 2022

I have Attiny85 and MAX485. I want to programming attiny by 485. I know that optiboot can change max485 in to "programming mode" by pin from attiny.

Is this option with pin isenabled default?

Or how compile own version? I tryied compile, but I have on any step error. I does this on windows and ubuntu. Is any tutorial step by step?

Now I have that result (this run from Git Bash):

psiek@dell MINGW64 ~/Downloads/optiboot-master/optiboot/bootloaders/optiboot
$ make attiny85at8
C:/WinAVR-20100110/utils/bin/make attiny85 AVR_FREQ=8000000L BAUD_RATE=19200
make[1]: Entering directory `C:/Users/dell/Downloads/optiboot-master/optiboot/bootloaders/optiboot'
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 19200, Real: 19230, UBRRL = 51, Difference=0.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=attiny85 -DF_CPU=8000000L  -DBAUD_RATE=19200 '-DLED_START_FLASHES=0'               '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART'   -c -o optiboot.o optiboot.c
optiboot.c:498: warning: 'leaf' attribute directive ignored
optiboot.c:499: warning: 'leaf' attribute directive ignored
optiboot.c:566:2: error: #error "Can't find SPM or WDT interrupt vector for this CPU"
optiboot.c: In function 'main':
optiboot.c:830: error: 'save_vect_num' undeclared (first use in this function)
optiboot.c:830: error: (Each undeclared identifier is reported only once
optiboot.c:830: error: for each function it appears in.)
optiboot.c: In function 'read_mem':
optiboot.c:1530: error: 'save_vect_num' undeclared (first use in this function)
make[1]: *** [optiboot.o] Error 1
make[1]: Leaving directory `C:/Users/dell/Downloads/optiboot-master/optiboot/bootloaders/optiboot'
make: *** [attiny85at8] Error 2

```
@SpenceKonde
Copy link
Owner

Did you read #694?

Also, try using the 2.0.0-dev branch - all new development is happening there

@expertup
Copy link
Author

Did you read #694?

Yes, readed. Project now compiling correctly, but programming by RS485 not working. This is that same on https://github.com/Optiboot/optiboot (Optiboot/optiboot#348)

$ make attiny85 RS485=B2 LED_START_FLASHES=0 TIMEOUT=8 BAUD_RATE=19200
avr-gcc (GCC) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 19200, Real: 19230, UBRRL = 51, Difference=0.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=attiny85 -DF_CPU=8000000L  -DBAUD_RATE=19200 -DLED_START_FLASHES=0           -DRS485=B2 -DTIMEOUT=8   '-DVIRTUAL_BOOT_PARTITION' '-DLED_START_FLASHES=0' '-DSOFT_UART'   -c -o optiboot.o optiboot.c
optiboot.c: In function 'putch':
optiboot.c:1107:14: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds]
 1107 |   RS485_PORT &= ~_BV(RS485);
      |              ^~
optiboot.c: In function 'main':
optiboot.c:667:22: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds]
  667 |         MCUSTATUSREG &= ~(_BV(WDRF));
      |                      ^~
optiboot.c:788:14: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds]
  788 |   RS485_PORT &= ~_BV(RS485);
      |              ^~
In function 'read_mem',
    inlined from 'main' at optiboot.c:1010:7:
optiboot.c:1390:48: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
 1390 |         else if (address.word == saveVect1) ch = saveVect1_sav;
      |                                                ^
optiboot.c:1389:48: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
 1389 |         else if (address.word == saveVect0) ch = saveVect0_sav;
      |                                                ^
optiboot.c:1388:47: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
 1388 |         else if (address.word == rstVect1) ch = rstVect1_sav;
      |                                               ^
optiboot.c:1387:42: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
 1387 |         if (address.word == rstVect0) ch = rstVect0_sav;
      |                                          ^
optiboot.c: In function 'main':
optiboot.c:955:29: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  955 |     rstVect0_sav = buff.bptr[rstVect0];
      |                    ~~~~~~~~~^~~~~~~~~~
optiboot.c:529:23: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  529 | #define rstVect0_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+4))
      |                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:955:5: note: in expansion of macro 'rstVect0_sav'
  955 |     rstVect0_sav = buff.bptr[rstVect0];
      |     ^~~~~~~~~~~~
optiboot.c:956:18: warning: array subscript 1 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  956 |     rstVect1_sav = buff.bptr[rstVect1];
      |                  ^
optiboot.c:530:23: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  530 | #define rstVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+5))
      |                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:956:5: note: in expansion of macro 'rstVect1_sav'
  956 |     rstVect1_sav = buff.bptr[rstVect1];
      |     ^~~~~~~~~~~~
optiboot.c:959:14: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  959 |     buff.bptr[0] = vect.bytes[0]; // rjmp to start of bootloader
      |     ~~~~~~~~~^~~
optiboot.c:960:14: warning: array subscript 1 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  960 |     buff.bptr[1] = vect.bytes[1] | 0xC0;  // make an "rjmp"
      |     ~~~~~~~~~^~~
optiboot.c:978:23: warning: array subscript 12 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  978 |         saveVect0_sav = buff.bptr[saveVect0];
      |                       ^
optiboot.c:531:24: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  531 | #define saveVect0_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+6))
      |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:978:9: note: in expansion of macro 'saveVect0_sav'
  978 |         saveVect0_sav = buff.bptr[saveVect0];
      |         ^~~~~~~~~~~~~
optiboot.c:979:23: warning: array subscript 13 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  979 |         saveVect1_sav = buff.bptr[saveVect1];
      |                       ^
optiboot.c:532:24: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  532 | #define saveVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+7))
      |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:979:9: note: in expansion of macro 'saveVect1_sav'
  979 |         saveVect1_sav = buff.bptr[saveVect1];
      |         ^~~~~~~~~~~~~
optiboot.c:529:23: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  529 | #define rstVect0_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+4))
      |                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:980:25: note: in expansion of macro 'rstVect0_sav'
  980 |         vect.bytes[0] = rstVect0_sav;
      |                         ^~~~~~~~~~~~
optiboot.c:530:23: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  530 | #define rstVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+5))
      |                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
optiboot.c:981:25: note: in expansion of macro 'rstVect1_sav'
  981 |         vect.bytes[1] = rstVect1_sav;
      |                         ^~~~~~~~~~~~
optiboot.c:984:18: warning: array subscript 12 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  984 |         buff.bptr[saveVect0] = vect.bytes[0];
      |         ~~~~~~~~~^~~~~~~~~~~
optiboot.c:985:18: warning: array subscript 13 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  985 |         buff.bptr[saveVect1] = (vect.bytes[1] & 0x0F)| 0xC0;  // make an "rjmp"
      |         ~~~~~~~~~^~~~~~~~~~~
optiboot.c:988:18: warning: array subscript 0 is outside array bounds of 'uint8_t[0]' {aka 'unsigned char[]'} [-Warray-bounds]
  988 |         buff.bptr[0] = vect.bytes[0]; // rjmp 0x1c00 instruction
      |         ~~~~~~~~~^~~
In file included from c:\users\dell\programs\avr8-gnu-toolchain\avr\include\avr\io.h:99,
                 from optiboot.c:313:
In function 'writebuffer',
    inlined from 'main' at optiboot.c:997:7:
optiboot.c:1343:9: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds]
 1343 |         boot_spm_busy_wait();
      |         ^~~~~~~~~~~~~~~~~~
optiboot.c:1360:9: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds]
 1360 |         boot_spm_busy_wait();
      |         ^~~~~~~~~~~~~~~~~~
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=attiny85 -DF_CPU=8000000L  -DBAUD_RATE=19200 -DLED_START_FLASHES=0           -DRS485=B2 -DTIMEOUT=8   '-DVIRTUAL_BOOT_PARTITION' '-DLED_START_FLASHES=0' '-DSOFT_UART' -Wl,--section-start=.text=0x1c00 -Wl,--relax -nostartfiles -o optiboot_attiny85.elf optiboot.o
avr-size optiboot_attiny85.elf
   text    data     bss     dec     hex filename
    586       0       0     586     24a optiboot_attiny85.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_attiny85.elf optiboot_attiny85.hex
avr-objdump -h -S optiboot_attiny85.elf > optiboot_attiny85.lst
rm optiboot.o optiboot_attiny85.elf

Also, try using the 2.0.0-dev branch - all new development is happening there

Ok, I found this and will test. If there are any problems, I will describe it here

@expertup
Copy link
Author

RS485 TXRX dicerction communication need resistor pull up/down? In RS485=B2 pin level is very unstable and jumping. On about 2 weeks I wil have osciloscope.

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Dell\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2/avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         Setting bit clk period        : 5.0
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x0d
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0d

avrdude done.  Thank you.

Problem uploading to board.  See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.

@SpenceKonde
Copy link
Owner

I don't see anything obviously wrong in the code - but I never used the RS485 stuff myself.... that was added for someone else and declared by them to be working, then years later bill westfield submitted a PR that said rs485 was actually broken and supposedly fixing it. Nobody has ever tested it since, I don't think, and we do not distribute compiled binaries. But just looking at the size of the compiled binary, it doesn't look like the feature is taking up any space, implying that the option is getting lost.

I also can't recommend using such brand new versions of avr-gcc, as AVR is not watched as closely as say, x64 or ARM. Microchip uses 7.3 IIRC, same thing as arduino,, and nobody has their eye on the later gcc branches to make sure AVR has not regressed. It certainly doesn't seem to have progressed signficantly, and it, in effect, targets x64 and ARM and stuff like that increasingly, and offer little benefit to AVR, and nobody's even making sure they;re not accumulating mold (like that spurrious warning about array bounds which assumes 0 isn't a valid memory address (true on many platforms. Not true on AVR, and there's apparently a simple way to fix it, but nobody has jumped through the hoops needed to get that configuration setting for AVR changed in several versions of avr-gcc. My understanding is that most people use 7.3.

@SpenceKonde SpenceKonde added the Pre-2.0.0 bug Bug present in versions of the core older than 2.0.0 - needs to be reteted in 2.0.0 label Jul 4, 2022
@SpenceKonde SpenceKonde added this to the Some Future Version milestone Aug 14, 2022
@SpenceKonde
Copy link
Owner

Okay, I'm going to correct what I said previously - for Optiboot bootloaders, we use the 5.4.0 toolchain as we have gotten binaries that did not work correctly out of later ones. Adding support for new toolchain versions for legacy parts is not a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pre-2.0.0 bug Bug present in versions of the core older than 2.0.0 - needs to be reteted in 2.0.0
Projects
None yet
Development

No branches or pull requests

2 participants