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

[FR] build for Anet V1.0 / Anet V1.5 board with optiboot bootloader #22626

Closed
DerAndere1 opened this issue Aug 24, 2021 · 6 comments
Closed

[FR] build for Anet V1.0 / Anet V1.5 board with optiboot bootloader #22626

DerAndere1 opened this issue Aug 24, 2021 · 6 comments

Comments

@DerAndere1
Copy link
Contributor

DerAndere1 commented Aug 24, 2021

Is your feature request related to a problem? Please describe.

With my electronics, either comilation or upload fails, depending on what default_env I use.

Are you looking for hardware support?

Anet V1.0 board (actually, the board has "Anet V1.5" printed on it) with optiboot bootloader

Describe the feature you want

Ability to build + upload Marlin using VS Code according to info in pins_ANET_10.h.

Currently, optiboot requires one of the following workarounds:

Alternative A:

WARNING: This workaround is not intended for users with the stock bootloader. It may corrupt the stock bootloader

#include "sanguino/pins_ANET_10.h" // ATmega1284P env:sanguino1284p env:sanguino1284p_optimized
change to

  #include "sanguino/pins_ANET_10.h"            // ATmega1284P                            env:sanguino1284p env:sanguino1284p_optimized env:melzi_optiboot

For consistancy,

#error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')"
change to

  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p', or 'sanguino1284p_optimized'. With optiboot, use 'melzi_optiboot')."

#error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')"
change to

  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p', or 'sanguino1284p_optimized'. With optiboot, use 'melzi_optiboot')."

This allows the user to build and upload after setting default_env = melzi_optiboot in platformio.ini .

Alternative B:

WARNING: This workaround is not intended for users with the stock bootloader. The firmware upload may fail with the stock bootloader.

Marlin/ini/avr.ini

Lines 103 to 107 in 7974dcd

[env:sanguino1284p]
platform = atmelavr
extends = common_avr8
board = sanguino_atmega1284p
board_upload.maximum_size = 126976
change to:

[env:sanguino1284p]
platform                  = atmelavr
extends                   = common_avr8
board                     = sanguino_atmega1284p
board_upload.maximum_size = 126976            # TODO: This may be set to 130048 when using optiboot
upload_speed        =  115200

For consistancy,

#error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')"
change to

  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p', or 'sanguino1284p_optimized'. With optiboot, use 'sanguino1284p' and verify that 'upload_speed = 115200')."

#error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')"
change to

  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p', or 'sanguino1284p_optimized'. With optiboot, use 'sanguino1284p' and verify that 'upload_speed = 115200')."

This allows the user to build and upload after setting default_env = sanguino1284p in platformio.ini .

Additional context

the melzi_optiboot option was removed for the Anet V1.0 board in PR #17120 to prevent users with stock bootloader to exceed firmware size limit of 126976 bytes.

@DerAndere1 DerAndere1 added the T: Feature Request Features requested by users. label Aug 24, 2021
@DerAndere1
Copy link
Contributor Author

@kreuzhofer as the author of the cited pull request, do you have a preferred build procedure for the Anet V1.0 board with optiboot bootloader ?

@thinkyhead
Copy link
Member

thinkyhead commented Aug 24, 2021

For an alternative build with a different start address or other modifications, we must add a new environment entry to the avr.ini file.

@DerAndere1
Copy link
Contributor Author

DerAndere1 commented Aug 24, 2021

I found this https://docs.platformio.org/en/latest/boards/atmelavr/sanguino_atmega1284p.html#configuration which says

You can override default Sanguino ATmega1284p (16MHz) settings per build environment using board_*** option, where *** is a JSON object path from board manifest sanguino_atmega1284p.json. For example, board_build.mcu, board_build.f_cpu, etc.

EDIT: Looking at platformio/platform-atmelavr#217 it seems that board_upload.maximum_size is the relevant setting. Size for the optiboot bootloader for sanguino1284P, 16MHz, baudrate 115200 is 632 bytes according to https://github.com/MCUdude/optiboot_flash/blob/master/bootloaders/atmega1284p/atmega1284p_build_info.txt . So 1024 bytes will be allocated to the bootloader. Total flash size is 131072, So we can set board_upload.maximum_size = 130048

@DerAndere1
Copy link
Contributor Author

DerAndere1 commented Aug 25, 2021

The reason why melzi_optiboot was disallowed for anet 1.0 in PR #17120 does not exist anymore since PR #18502 . But since PR platformio/platform-atmelavr#217 was merged into PlatformIO, the board file specifies the complete flash size (maxiumsize = 131072,). Since then, the melzi_optiboot environment was probably broken for all boards: We now need to have board_upload.maximum_size = ... in all envs to account for the bootloader size. I edited my proposal in the initial request and will prepare a PR. I think we should edit pins.h to allow users with Anet 1.0 board to set default_env = melzi_optiboot because the name of the environment makes its purpose obvious, especially if we document everything in the pins_ANET_10.h file.

@thisiskeithb
Copy link
Member

Support added in #22630

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants