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

Problem: No AVR support and path issues on windows #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

argltuc
Copy link

@argltuc argltuc commented May 14, 2021

Solution:

  • Add minimal generic MCU support for AVR ATtiny and ATxmega
  • fix compiler path detection on windows

Tested against:

  • Windows 10 20H2
  • CMake 3.20
  • Ninja / Ninja Multi-Config
  • Microchip xc8 v2.31 at default windows install path

# known 8-bit MCU families
list(APPEND MICROCHIP_FAMILIES_8
PIC12F
PIC16F
PIC18F
ATtiny
ATxmega
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about ATmega parts?

Copy link
Author

@argltuc argltuc May 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have any test hardware for ATmega. I can add it, but untested.

Copy link
Contributor

@enbyted enbyted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work 👍

I've suggested some changes, but keep in mind that I'm just a random dude that happens to use this project a lot - not in any way involved.



function(avr_obj2hex target)
find_program(AVR_OBJ2HEX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to name it AVR_OBJCOPY as it's more descriptive.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, since there is already a MicrochipBin2Hex.cmake it feels for me more suitable.
On the other hand, since I do not develop our MCU software, but manage the CI and test final hardware, this naming is a little helper, that this function gives the files for program the device ;) I know... weak arguments ^^
OBJCOPY directly fits to the called avr program, so there is a better connection for typical developer...

At the end, I found this cmake file once somewhere, it is from the owner of this Repository, and I think it would be nice, if we can discuss the naming with him (and hopefully also other users)

add_custom_command(
TARGET ${target} POST_BUILD
WORKING_DIRECTORY ${dir}/$<CONFIG>
COMMAND "${AVR_OBJ2HEX}" -O ihex "${in_f}$<$<CONFIG:DEBUG>:${CMAKE_DEBUG_POSTFIX}>.elf" "${out_f}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it easier to customize consider adding a variable AVR_OBJCOPY_FLAGS (AVR_OBJ2HEX_FLAGS) and maybe appropriate target property for more complex projects.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uff, feel free ;) This is behind my knowladge of AVR_OBJCOPY ;)

elseif(MICROCHIP_MCU MATCHES "^(AT)(tiny|xmega)([a-zA-Z0-9]+)$")
set(MICROCHIP_MCU_FAMILY "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
set(MICROCHIP_MCU_MODEL "${MICROCHIP_MCU}")
if(MICROCHIP_MCU_FAMILY IN_LIST MICROCHIP_FAMILIES_8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building a test program to check if the compiler actually supports the CPU would make error messages nicer - i.e. a descriptive error during configure instead of during compile (though still descriptive).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This idea sounds good. but as above: feel free :)
I can try to manage a configuration test, but i will need some time for it. I want to use this toolchain for some of our components and I just want to share my adaptions, which I made to fit my purposes, so a configuration test is currently not on my way :)

@argltuc
Copy link
Author

argltuc commented Jan 16, 2023

If current function AVR_OBJ2HEX is used the resulting hex file is maybe flashable with Microchip Studio but it is not sure if one can use avrdude for flashing. Usage of avrdude can result in out of range of memory addresses.
Microchip Studio calls avr-objcopy from XC8 with additional parameters: -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures. So created hex files are flashable with avrdude.
In my opinion it is not usefull to add these parameters as default to AVR_OBJ2HEX function, so i extend the function call to support additional parameters and let the user decide, which parameters are usefull for a given project.

This current project state is used since one year for massive CI generated firmware roll outs based on ATxmega256 and ATtiny1627 and XC 2.3x and 2.40 (XC 2.40 should be prefered with this both MCU since a couple of API corrections are made by Microchip in last 2 years). With these changes our resulting hex files are now automaticly flashed to the hardware.

@enbyted
Copy link
Contributor

enbyted commented Jun 3, 2024

Hey @argltuc,

Since this repo seems to be more or less unmaintained I am happy to take this change into my fork: https://github.com/enbyted/cmake-microchip

If you're okay with that please open a PR there, against xc8-cc branch.

@argltuc
Copy link
Author

argltuc commented Jun 3, 2024

Hi @enbyted,
thanks for your response and offer. i will create the PR during the next days, since i work on some eeprom support stuff ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants