-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
Settings fuses for Atmel AVR MCUs #865
Comments
It's a good example, but I'm limited to just a couple of ATtiny chips. I also want to be able to run something like I've created a lot of Arduino cores, to add support for the most popular AVRs out there. My philosophy has allways been to keep it simple, but easily confurable. I'll love to add support for some AVR microcontrollers under the "Atmel AVR" category. Does there exist any guides out there on how to add support for mor hardware? avr-gcc and avrdude is allready working, so there shouldn't be a huge job get it to work. In the first round I'd like to add the ATmega1284/P, ATmega644/P/PA, ATmega324/P/PA, ATmega164P/PA, ATmega32, ATmega16 and ATmega8535 😃 |
{
"build": {
"core": "MightyCore",
"extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega324",
"f_cpu": "16000000L",
"mcu": "atmega324p",
"variant": "mightycore"
},
"frameworks": [
"arduino"
],
"name": "MightyCore ATmega324",
"upload": {
"maximum_ram_size": 2048,
"maximum_size": 32256,
"protocol": "arduino",
"require_upload_port": true,
"speed": 115200
},
"url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board",
"vendor": "Mcudude"
}
EDIT: The modified JSON file (atmega8515.json) looks like this: {
"build":
{
"mcu": "atmega8515",
"f_cpu": "",
"variant": ""
},
"name": "Generic ATmega8515",
"upload":
{
"maximum_size": 8192,
"maximum_ram_size": 512,
"protocol": "",
"extra_flags": ""
},
"url": "https://github.com/MCUdude/PlatformIO_AVR",
"vendor": "Generic ATmega8515"
} Does it looks OK? It compiles without any errors, but does is miss anything significant? The platfromio.ini file looks like this: [env:native_avr]
;Platform
platform = atmelavr
;Microcontroller
board_mcu = atmega8515
;Clock frequency
board_f_cpu = 16000000L
;Programming tool
upload_protocol = stk500
;Avrdude extra options
upload_flags = -P COM7 -e How can I change/add a new environment name, such as avr_atmega8515? |
What is a difference between this manifest? Here are located all AVR-based manifests for boards:
PlatformIO is very flexible build system. You can extend it with an own target, such as
I think that we can have built-in Here is a list of default targets for ATMEL AVR development platform: |
MightyCore is the name of an Arduino add-on for adding support for a handful of pin compatible micro controllers, including the ATmega8535. While the MightyCore add-on for Arduino IDE lets the user configure clock frequencies, brown-out detection and pinout, the PlatformIO doesn't have any. I'm a Mac user which uses Arduino IDE and avr-gcc+ make files to program AVRs. At work I'm using a windows machine, and everybody knows that the windows command line is just terrible. I was hoping that I could use PlatformIO at work (on my PC) and at home (on my mac), and still be able to configure the microcontroller options like I can with my own MightyCore and with avr-gcc+makefiles. I'm really close, but I'm not able to set the fuses using PlatformIO yet. I'm sure a lot of AVR devs would love using PlatformIO if the MCU settings was more configurable. If its possible to run something like |
In this case, a manifest will look like: {
"build":
{
"mcu": "atmega8515",
"f_cpu": "16000000L",
"variant": "standard"
},
"name": "Generic ATmega8515",
"upload":
{
"maximum_size": 8192,
"maximum_ram_size": 512,
"protocol": "stk500",
"extra_flags": "-e"
},
"url": "http://www.atmel.com/devices/atmega8515.aspx",
"vendor": "Generic ATmega8515"
} and [env:native_avr]
platform = atmelavr P.S: Before pulling a request to PIO Atmel AVR repo, you can test own manifests from boards directory that is located in project folder.
That is why PlatformIO was developed - to provide the same workflow on the different host machines (Win, Linux, FreeBSD, macOS, etc) That is very easy. Please explain me how final |
This is great, thank you!! 😃 This only issue here is that "older" AVRs, such as ATmega8535, ATmega8515, ATmega16 and ATmega32 doesnt have an extended fuse. Avrdude will return an error if the command above is used to set the fuses for the 8535, 16 or 32. I solved this by doing a small change to avrdude.conf - the file where all microcontroller info is stored. If this mod is applied, Avrdude would just ignore the empty efuse field. When all this is wraped up and finished; will it be possible to make PlatformIO automatically add these extra parameters to the platformio.ini file, so that the user doesn't have to type them manually in order to build, set fuses and upload code? Another question, I tried setting the f_cpu field in the json file as 16 MHz default ("f_cpu": "16000000L"), but then I wasn't able to redefine the f_cpu inside the main.c or platformio.ini file. |
I tried to add the atmega8515.json file (embedded below) to the atmelavr/boards directory, but I get this error message when trying to create a new project using Atom. If I remove the file, everything is working just fine. Are there any files missing?
atmega8515.json: {
"build":
{
"mcu": "atmega8515",
"f_cpu": "",
"variant": ""
},
"name": "Generic ATmega8515",
"upload":
{
"maximum_size": 8192,
"maximum_ram_size": 512,
"protocol": "",
"extra_flags": ""
},
"url": "https://github.com/MCUdude/PlatformIO_AVR",
"vendor": "Generic ATmega8515"
} |
See my changes: |
If you want to overwrite some data, you should specify them. I see you didn't do that. Please specify |
bootloader? The native AVRs doesn't use a bootloader. Is this to unify all "avr boards", so that the ones that doesn't use a bootloader simply just leaves a blank field? |
OK, how we should name this section in board config? Just |
I think |
Thanks, done! Please test it. Later we will discuss PRs with your generic boards and make final release of Atmel AVR development platform. |
Please specify |
Great, I'll dig out my old UNO and test it tomorrow. It's past midnight here in Norway 😉 Thank you for the fast response and even bothering implementing this! |
~~I'm able to set the fuses on my Arduino uno using the It turned out I had to use the term board instead of board_mcu. [env:avr_atmega8515]
;Platform
platform = atmelavr
;Microcontroller
board = atmega8515
;Clock frequency
board_f_cpu = 16000000L
;Programming tool
upload_protocol = stk500
;Avrdude extra options
upload_flags = -P COM7 -e -v
The current atmega8515.json file looks like this: {
"build":
{
"mcu": "atmega8515",
"f_cpu": "1000000L",
"variant": "standard"
},
"upload":
{
"maximum_size": 8192,
"maximum_ram_size": 512,
"protocol": "",
"extra_flags": ""
},
"fuses":
{
"low": "0xC1",
"high": "0xD9",
"extended": "0xff",
"unlock": "0x3F"
},
"name": "ATmega8515",
"url": "http://atmel.com",
"vendor": "Atmel AVR"
} I inserted the default (factory set) clock frequency and fuses (internal 1 MHz oscillator), so that these settings is applied if no fuses or clock frequency are specified. The only "fuses related" issue it to deal with the missing efuse on older AVRs. when setting the fuses for the ATmega8515, I get this warning and error:
|
Please totally remove this line from config. See |
We can check all these fuses. If a board doesn't have |
Ok, now all fuses are dynamic. Please be careful and specify correct keys for fuses. See my latest commit |
IMO this is the correct way of doing it! I've reinstalled the
the atmega8515.json file looks like this: {
"build":
{
"mcu": "atmega8515",
"f_cpu": "16000000L",
"variant": "standard"
},
"upload":
{
"maximum_size": 8192,
"maximum_ram_size": 512,
"protocol": "",
"extra_flags": ""
},
"fuses":
{
"lfuse": "0xC1",
"hfuse": "0xD9",
"lock": "0x0F"
},
"name": "ATmega8515",
"url": "http://atmel.com",
"vendor": "Atmel AVR"
} and the ini file looks like this: [env:avr_atmega8515]
;Platform
platform = atmelavr
;Microcontroller
board = atmega8515
;Clock frequency
board_f_cpu = 16000000L
;Programming tool
upload_protocol = stk500
;Avrdude extra options
upload_flags = -P COM9
;Fuses
;lfuse = 0xFF
;hfuse = 0xd4
;lock = 0x0f Oh! What's the magic keyword for changing the lfuse, hfuse and lock fuse inside the ini file? |
Fixed in platformio/platform-atmelavr@b8596f0
You can't set fuses in What is more, I think that we can rename existing |
You're absolutely sure it's not possible to find a way to change the fuses within the initial file? Configurable fuses is very important when developing for AVR. On the Arduino platform all the fuses and settings are allready preset, but on bare bone AVR you need the full control. Let's say I've been working with a project at work, and have done some changes to the fuses in the manifest file. When I get home and continue to work on the same project (shared on Dropbox or Drive), I'm working with an other manifest file with different fuses. If I'm going to set the fuses again, I'll have to edit this manifest file as well. This is a huge downside, because I might have multiple projects that uses the same manifest file, but have different fuses, depending on application.
I personally would add a couple of extra manifest files in order to make the list as self explaining clean as possible. Like mentioned earlier, the MightyCore*.Json. Files have all settings pre-configured, and doesn't need to be changed (Arduino). I think it's best to separate the generic AVR manifests and the Arduino manifests, because the default configurations are so different. |
PlatformIO allows overriding of built-in manifests. You can clone default manifest to Another way is to use extra_script and specify custom FUSESCMD.
Could you explain a difference between |
IMO I think the whose board list is quite messy. There are hundreds of boards, and many skared the same hardware (read: microcontroller), but with different configurations such as fuse settings, frameworks (native AVR, Arduino, Espressif SDK etc). Ideally the user should select what kind of hardware he/she's using when creating a project. Then the user should specify what kind of platform he/she's using. This may be harder to understand for beginners, but much more intuitive and elegant for the rest of us. What do you think? |
Do you mean PlatformIO IDE? Yes, it asks only about board now. However, we have started big work on PlatformIO IDE 2.0. I think that "New Project" wizard will be rewritten from a scratch. See P.S: What do wee need for resovling this issue? |
if it's possible to override the manifest by adding it to the project manually, the problem will be solved, as long as the user is able to find proper documentation on this. Is PlatformIO able to automatically copy the manifest file to the I'm curious to see how an extra script may be implemented. will this be as elegant as running a single command in the terminal? |
See http://docs.platformio.org/en/latest/platforms/atmelavr.html#fuses. You can use existing |
Great! Now should we add a separate section called "Atmel AVR", where we could add the following microcontrollers to the list:
I'm happy to create JSON files for these with the correct factory fuses, if they're going to be added to the list. All these are Arduino compatible, so there's a lot of resources online. |
How about to merge mighty*.json with your new board list mentioned above? |
The only problem by doing that is that the "Arduino" variants have different fuse settings than the native ones (16 MHz external oscillator vs. 1 MHz internal oscillator). |
I like this board IDs, like ATmega8, ATmega16, ATmega32, etc... How about to have ATmega8, ATmega16, ATmega32, etc...and use native fuses by default? In any case, user will be able to override default fuses. |
To be honest I find that a bit misleading info regarding how to set fuses. Tried this in my platform.ini (as suggested):
Content of extra_script_fuses.py:
Running "platformio run --target fuses" gives this:
Ehem... jenkins?? That's not me :) |
Hi!
I'm struggling to find any information on how to write and upload code to a generic AVR, such as the ATmega32, without depending on the Arduino framework.
Does there exist/is it possible to create something like this:
Where I can define the microcontroller, low fuse, high fuse and clock frequency, and be able to compile and upload within PlatformIO? Compiling for a generic AVR microcontroller with a specific clock frequency is as simple as running a single command using avr-gcc. Same goes with uploading. How can this be done be using PlatformIO?
The text was updated successfully, but these errors were encountered: